laravel-nova-nested-form
laravel-nova-nested-form copied to clipboard
Support for Laravel Nova 4
Hello,
I'm trying to update my project to Laravel Nova 4 and laravel-nova-nested-form is not compatible :
Log:
PHP Fatal error: Declaration of Yassi\NestedForm\NestedForm::jsonSerialize() must be compatible with Laravel\Nova\Fields\Field::jsonSerialize(): array in /var/www/html/vendor/yassi/nova-nested-form/src/NestedForm.php on line 555
Do you have in mind support it?
Thanks.
I would really like to see this happen. I managed to get quite far, but at this point it's telling me that it can't find the property on the Nova model that contains the NestedForm
rather than the Nova model the NestedForm
is containing.
use App\Models\PostModel;
use Yassi\NestedForm\NestedForm;
class Post extends Resource
{
public static string $model = PostModel::class;
// ...
public function fields(Request $request): array
{
return [
// ...
NestedForm::make(__('Users'), 'users', 'App\Nova\User')
];
}
}
// Call to undefined method App\Models\Post::role()
Where that call should obviously have been to App\Models\User::role()
.
@pindab0ter Any updates on your attempt?
Unfortunately not. I lack the experience with Vue.js and Nova extensions in general to finish this.
Hi guys, I'm close to solve an issue, I guess on this or next week, module will be relased.
https://github.com/handleglobal/laravel-nova-nested-form
Seems we have first working version, with a lot of bugs I guess and dirty hacks, but it working. Changes already in repo
https://github.com/handleglobal/laravel-nova-nested-form
related to
LOG.warning: Return type of Yassi\NestedForm\NestedFormSchema::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/yassi/nova-nested-form/src/NestedFormSchema.php on line 179
@buchkovsky Latest Nova version upgrade (4.17.1) seems to break your fork:
[2022-10-31 11:56:23] local.ERROR: Method App\Nova\BookCharacter::removeNonUpdateFields() does not exist {"userId":1,"exception":"[object] (ReflectionException(code: 0): Method App\\Nova\\BookCharacter::removeNonUpdateFields() does not exist at /home/jon/PhpstormProjects/laravel-scholieren/vendor/handleglobal/nova-nested-form/src/NestedFormSchema.php:198)
Nova 4.16.1 still works so we're reverting the upgrade
@buchkovsky could you open a PR so maybe @yassilah or @alberto-bottarini can take a look at it.
@buchkovsky Latest Nova version upgrade (4.17.1) seems to break your fork:
[2022-10-31 11:56:23] local.ERROR: Method App\Nova\BookCharacter::removeNonUpdateFields() does not exist {"userId":1,"exception":"[object] (ReflectionException(code: 0): Method App\\Nova\\BookCharacter::removeNonUpdateFields() does not exist at /home/jon/PhpstormProjects/laravel-scholieren/vendor/handleglobal/nova-nested-form/src/NestedFormSchema.php:198)
Nova 4.16.1 still works so we're reverting the upgrade
@Jon78 @buchkovsky looks like methods moved to FieldCollection but
using
protected static $filterMethod = 'updateFields';
instead of https://github.com/yassilah/laravel-nova-nested-form/blob/f1fa36a2d359d75a334cc3f7596dbd2f5de2e83e/src/NestedFormChild.php#L16
and
protected static $filterMethod = 'creationFields';
instead of https://github.com/yassilah/laravel-nova-nested-form/blob/f1fa36a2d359d75a334cc3f7596dbd2f5de2e83e/src/NestedFormSchema.php#L48
should resolve the same?
check vendor/laravel/nova/src/ResolvesFields.php
Good find!
https://github.com/handleglobal/laravel-nova-nested-form/pull/5
@buchkovsky @chrillep guys is this fork working for 2 nestings? because lets say I have
Resource1
- hasMany Resource2
Resource 2
- hasMany Resource3
And when I am trying to create Resource1 I add 2 times Resources 2 and foreach Resource 2 I am adding Resource3 but the form throws and exception:
Column not found: 1054 Unknown column 'resource_1_id' in 'field list' (Connection: mysql, SQL: insert into resources3
(type
, resource_1_id
, updated_at
, created_at
) values (......)
to me its mistery why it is trying to insert in resources3 table when the values I can see it is for resource2. somehow it guessed the wrong model
@buchkovsky @chrillep guys is this fork working for 2 nestings? because lets say I have
Resource1
- hasMany Resource2
Resource 2
- hasMany Resource3
And when I am trying to create Resource1 I add 2 times Resources 2 and foreach Resource 2 I am adding Resource3 but the form throws and exception:
Column not found: 1054 Unknown column 'resource_1_id' in 'field list' (Connection: mysql, SQL: insert into
resources3
(type
,resource_1_id
,updated_at
,created_at
) values (......)to me its mistery why it is trying to insert in resources3 table when the values I can see it is for resource2. somehow it guessed the wrong model
IDK i don't use it anymore. I believe i had a fork but can't remember :)
@chrillep I posted the same question just above yours. One solution that I have found is to use NestedFrom for the first resource and in the second one use Repeater (new Laravel Nova field) and it works. But somehow now the validation on the first nested resource is not appearing when submitting the form (when creating). it is actually validating it and frontend does not show the error. When doing and update the error appears though. But when the form is valid is creates all resources correctly.
p.s. Unfortunately DependencyContainer does not work on those fields
any news on this one?