If you are passing a null value intended then go into your database migration and stick ->nullable() on the end of currency. If you have not intended the value you to be null, you should check your front end and the value being passed. A good start is to dd($form).
Dec 24, 2023
4
Level 2
Modal in fillament
I wrote this code, but there is a problem,
public static function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('First Step')
->schema([
TextInput::make('title')->required(),
Forms\Components\Actions::make([
Action::make('Custom Modal')
->button()
->form([
TextInput::make('price')->prefix('$')->required(),
])
]),
Wizard\Step::make('Second Step')
->schema([
//...
]),
]),
]);
}
when I submit the form it passes this error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'currency' cannot be null.
Generally it doesn't work for every column that I put in modal.
Level 2
After testing a lot of ways, Now this is the answer:
....
Wizard\Step::make('First Step')
->schema([
TextInput::make('title')->required(),
Hidden::make('price'),
Forms\Components\Actions::make([
Action::make('Custom Modal')
->button()
->form([
TextInput::make('price')->prefix('$')->required()
->default(
function (MyModel $record = null) {
return $record?->price;
}
),
])
->action(function (Set $set, array $data) {
$set('price', $data['price']);
}),
]),
]),
....
1 like
Please or to participate in this conversation.