Hi
I have a model that has relationship with user model so I need to add the user_id before saving the form. Here is my code in protected funtion form():
$form->saving(function (Form $form) {
// $form->text('user_id')->value(Admin::user()->id);
$form->user_id = Admin::user()->id;
});
I tried $form->user_id = Admin::user()->id; and $form->text('user_id')->value(Admin::user()->id); but still did not work. The user_id is inserted as NULL
The model $fillable already set with these cols
When I add $form->hidden('user_id')->value(Admin::user()->id); that works fine.
Do I miss something?
Thanks
P/S: I make somes tests by adding:
$form->user_id = Admin::user()->id;
$form->testing_1 = Admin::user()->id;
$form->desc = 'isdji ajsd s ' . Admin::user()->id;
Only desc col get added the user id but not the other 2.
mdoel-form only saves column data which defined as a field in the form.
Try this:
$form->hidden('user_id');
$form->saving(function (Form $form) {
$form->user_id = Admin::user()->id;
});
That works
Thanks
mdoel-formonly saves column data which defined as a field in the form.Try this:
$form->hidden('user_id'); $form->saving(function (Form $form) { $form->user_id = Admin::user()->id; });
Hello,
I tried to follow this example, but it did not work.
Error



My Model

Table Artigo

Table Admin_users

Do you have any tips on what I should do?
mdoel-formonly saves column data which defined as a field in the form.Try this:
$form->hidden('user_id'); $form->saving(function (Form $form) { $form->user_id = Admin::user()->id; });
That fixed my problem
Most helpful comment
mdoel-formonly saves column data which defined as a field in the form.Try this: