Closed danielbehrendt closed 4 years ago
Can you please post your component code.
<?php
namespace App\Http\Livewire\Shop;
use App\Models\Tenant\Shop;
use Livewire\Component;
use Tanthammar\TallForms\Input;
use Tanthammar\TallForms\TallForm;
class ShopForm extends Component
{
use TallForm;
/**
*
* @return void
*/
public function mount(?Shop $model)
{
$this->fill([
'formTitle' => null,
'showGoBack' => true,
'wrapWithView' => false,
'onKeyDownEnter' => '',
'inline' => false,
]);
$this->mount_form($model);
}
/**
*
* @return array
*/
public function fields()
{
return [
Input::make('Name')
->rules(
$this->model->exists ? 'required|unique:shops,name' : 'required|unique:shops,name,' . $this->model->id
),
];
}
}
@btw: I had to set onKeyDownEnter
this way, otherwise there will be also an error:
Argument 1 passed to Tanthammar\TallForms\Components\Form::__construct() must be of the type string, null given
Removing won't work.
Thank you for letting me know about onKeyDownEnter
, i released a fix for it.
Regarding your code example, I am unable to reproduce your error.
I do not have the Shop class so I did like this and it is working with and without model.
Route::get('/issue-test/{user?}', \App\Http\Livewire\App\IssueTestForm::class);
<?php
namespace App\Http\Livewire\App;
use App\User;
use Livewire\Component;
use Tanthammar\TallForms\Input;
use Tanthammar\TallForms\TallForm;
class IssueTestForm extends Component
{
use TallForm;
/**
*
* @param User|null $user
* @return void
*/
public function mount(?User $user)
{
$this->fill([
'formTitle' => null,
'showGoBack' => true,
'wrapWithView' => false,
'inline' => false,
]);
$this->mount_form($user);
}
/**
*
* @return array
*/
public function fields()
{
return [
Input::make('Name')
->rules(
$this->model->exists ? 'required|unique:shops,name' : 'required|unique:shops,name,' . $this->model->id
),
];
}
}
I also tried to place the component in a view
<livewire:app.issue-test-form :user="\App\User::first()" />
Thank you for the fix!
Do you have any published views from v3 that might cause the conflict?
No. Removed everything to start from scratch.
Do you have any published config from v3?
No. Removed old config and published the new one.
Can it be the model binding? Should it be (?Shop $shop)?
Model binding looks like this:
<livewire:shop.edit-form :shop="$shop" />
and componentent updated to this:
public function mount(?Shop $shop)
{
$this->fill([
'formTitle' => null,
'showGoBack' => true,
'wrapWithView' => false,
'inline' => false,
]);
$this->mount_form($shop);
}
The error also occurs on create.
Also tested with \App\User. I'm still getting this error. Really strange.
Maybe it helps to find the problem, the Select
field also throws an error:
Undefined variable: options (View: vendor/tanthammar/tall-forms/resources/views/components/select.blade.php)
Laravel 7?
yes
Is the component wrapped with another component or view?
Is the component wrapped with another component or view?
No.
@extends('layouts.tenant', ['title' => 'Shops'])
@section('content')
<div>
<div class="shadow overflow-hidden sm:rounded-md">
<div class="px-4 py-5 bg-white sm:p-6">
<livewire:shop.edit-form :shop="$shop" />
</div>
</div>
</div>
@endsection
So you have an almost blank app.blade.php and the form?
Do you have the Livewire v2 required {{ $slot }} somewhere?
@extends('layouts.base')
@section('body')
@yield('content')
{{$slot ?? null}}
@endsection
Do you have the Livewire v2 required {{ $slot }} somewhere?
@extends('layouts.base') @section('body') @yield('content') {{$slot ?? null}} @endsection
No, that was missing. But has no effect.
From the livewire docs
<!-- Before -->
<html>
<body>
@yield('content')
@livewireScripts
</body>
</html>
<!-- After -->
<html>
<body>
{{ $slot }}
@livewireScripts
</body>
</html>
Yes, I've updated this. Also have
<!-- Blade UI Kit Scripts -->
@bukScripts
@tanthammar Checkboxes are working as expected.
I will have to up a new project. But I don't have the time now. Will get back to you in a an hour or two. Have no issues in my local repo.
Now I have tested this with a fresh installation of Laravel 7, and while I was at it, I also tested Laravel 8 Jetstream. I had no issues like you are describing. Sorry.
@danielbehrendt Have you gotten any further with this? Didn't hear back from you yesterday. Would really like to know where this is coming from.
@tanthammar This is really strange. Yesterday I've setup a fresh Laravel (going up to v8) and installed all my required packages. Now I've got it running but I do have some other side effect (also with Livewire). I'll have to do so some more debugging, and I'll share any new insights here.
@danielbehrendt Thank you for letting me know. Looking forward to your feedback.
@danielbehrendt just a thought:
Could you new up a project using Laravel 8 Jetstream, --stack Livewire, no --teams? Don't install any of your components. Do you still have issues? That is what I did when testing yesterday.
Which packages are you using? Maybe there is a Livewire conflict with them? Are you using the latest AlpineJS version? Any errors in console?
@tanthammar That's really strange. Now that I have a fresh stack (without Jetstream) everything works fine.
One thing I've noticed (already in Livewire v1) is that multiple checkboxes are not getting checked correctly if they were clicked quickly one after the other. Do you have this problem too?
Checkboxes: That is due to the network request. Set ->wire('wire:model.defer) You'll loose out on real-time validation but the problem is gone. The field will be validated on submit.
This issue: All is working for you now? Can this issue be closed?
@tanthammar everything is working now and v2 is looking fantastic! This issue can be closed.
@danielbehrendt Did you ever find out what was wrong with your installation, that broke Livewire and this package?
@tanthammar No, unfortunately (or luckily) not. I'm not able to reproduce the errors.
I'm always getting errror in v4:
Undefined variable: temp_key (View: vendor/tanthammar/tall-forms/resources/views/components/input.blade.php)