Let's say I have a relationship invoiceLines used in form with the hasMany field, the creation form works perfectly (database proves it), but when editing the form, I get this error:
ErrorException In HasMany.php line 359 :
Invalid argument supplied for foreach() (View: C:\xampp\htdocs\laravel-admin\vendor\encore\laravel-admin\views\form.blade.php)
With the following form snippet
$form->hasMany('invoiceLines', function(Form\NestedForm $form) {
$form->decimal('amount');
$form->number('quantity');
});
It is seems to work if I put all the relationship name all in lowercase
$form->hasMany('invoicelines', ...
While keeping the relationship in my model camel-cased.
I still think it could be looked into because it can lead to mistakes and maybe hiding other bugs...
Same thing happens with $form->multipleSelect()
It silently fails (no error or exception), not saving and losing the pivot data.
Setting the field name in lowercase fixes the problem.
@isometriq I had the same issue with camel cased relationships in nested forms, your solution worked. Thanks
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
It is seems to work if I put all the relationship name all in lowercase
$form->hasMany('invoicelines', ...While keeping the relationship in my model camel-cased.
I still think it could be looked into because it can lead to mistakes and maybe hiding other bugs...