F
Filament5mo ago
Darnes

error on createOptionsForm in multiple forms in livewire page

Missing [$rules/rules()] property/method on: [App\Livewire\Buy\InpBuy]. this error message when press add button in CreateOptionForm in livewire page with multiple forms. Although the same CreateOptionForm with the same code work well in other resource page.
7 Replies
Darnes
Darnes5mo ago
any help Plz
Andrew Wallo
Andrew Wallo5mo ago
Show your code and maybe someone will be able to help you. We have no idea what you could be talking about.
Darnes
Darnes5mo ago
This the code of Select (in livewire page) Select::make('supplier_id') ->label('المورد') ->relationship('Supplier','name') ->live() ->required() ->inlineLabel() ->columnSpan(3) ->afterStateUpdated(function ($state){ $res=Buys_work::find($this->buy_id); $res->supplier_id=$state; $res->save(); }) ->createOptionForm([ Section::make('ادخال مورد جديد') ->schema([ TextInput::make('name') ->required() ->label('الاسم'), TextInput::make('address') ->label('العنوان'), TextInput::make('mdar') ->label('مدار'), TextInput::make('libyana') ->label('لبيانا'), Hidden::make('user_id'), ]) ]) the same code is in other resource page work , but in this page the modal of create is open and after I fill data and press add button show error (Missing [$rules/rules()] property/method on: [App\Livewire\Buy\InpBuy].) other note : in this page there are two forms
Andrew Wallo
Andrew Wallo5mo ago
What exactly are you trying to do here?
->afterStateUpdated(function ($state){
$res=Buys_work::find($this->buy_id);
$res->supplier_id=$state;
$res->save();
})
->afterStateUpdated(function ($state){
$res=Buys_work::find($this->buy_id);
$res->supplier_id=$state;
$res->save();
})
It doesn't seem conventional to do an Eloquent operation such as $res->save() within a afterStateUpdated() method. That is why I am asking
Darnes
Darnes5mo ago
it work well (I mean afterStateUpdated) , even when I removed the afterStateUpdated the same error rise. the error rise when CreateOptionForm . other than that every things are work well.
Andrew Wallo
Andrew Wallo5mo ago
Well it’s probably something else in your component then. Is your relationship method name supposed to be uppercased for the first letter? Maybe change it to “supplier” instead.
Darnes
Darnes5mo ago
yes it is uppercase.