You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the plugin among other things to manage articles and, directly when creating, to be able to deposit one or more article images.
Furthermore, I use an observer for the articles, which after an article has been created under certain circumstances saves it again.
In the file vendor/yassi/nova-nested-form/src/NestedForm.php in line 342 a saved hook is used, which in my circumstances ensures that the article image is created directly several times.
After I changed the hook to created, the error no longer occurs. However, I don't know if this could cause other problems.
Here is the excerpt from the code of the corresponding place:
Hmm I see what the problem is. It's not possible to use the "created" hook as this would then prevent the nested form relationships to be updated when the parent already exists (hence the use of the "saved" hook, which is called both on creation and on update). However, it might be possible to use something like this:
$eventName = 'nested-form:saved';
$dispatcher = $model::getEventDispatcher();
$model::registerModelEvent($eventName, function ($model) use ($request, $requestAttribute, $attribute, $eventName) {
$this->fillAttributeFromRequest($request, $requestAttribute, $model, $attribute);
if ($dispatcher) {
$dispatcher->forget("eloquent.{$eventName}");
}
});
$model::saved(function ($model) use ($request, $requestAttribute, $attribute, $eventName) {
$model->fireModelEvent($eventName);
});
Could you try that out and let me know if that's what you're looking for?
The fireModelEvent function is protected, therefore not callable like in your example. But that seems like a possible solution if you add a custom Trait of your NestedForm Plugin to the model with a fireNestedFormEvent method which then calls the fireModelEvent method directly in the model itself?!
I use the plugin among other things to manage articles and, directly when creating, to be able to deposit one or more article images.
Furthermore, I use an observer for the articles, which after an article has been created under certain circumstances saves it again.
In the file
vendor/yassi/nova-nested-form/src/NestedForm.php
in line342
asaved
hook is used, which in my circumstances ensures that the article image is created directly several times.After I changed the hook to
created
, the error no longer occurs. However, I don't know if this could cause other problems.Here is the excerpt from the code of the corresponding place:
The text was updated successfully, but these errors were encountered: