laravel-nova-nested-form
laravel-nova-nested-form copied to clipboard
Validation messages are not displayed
- Laravel version: 7.16
- Nova version: 3.6
- PHP version: 7.4
- yassi/nova-nested-form: 3.0.7
I have configured NestedForm in a field, but creating a record with missing mandatory fields does not show me the errors in each field.
I show you how I have everything configured.
Models
...
class Order extends Model
{
...
public function notifications()
{
return $this->hasMany(\App\OrderNotification::class);
}
...
}
...
class OrderNotification extends Model
{
...
public function order()
{
return $this->belongsTo(\App\Order::class);
}
...
}
Nova Resources
...
class Order extends Resource
{
...
public function fields(Request $request)
{
$nestedOrderNotifications = NestedForm::make(__('Notifications'), 'notifications', OrderNotification::class);
$nestedOrderNotifications
->max(1)
->heading('')
->hideWhenUpdating();
return [
$this->buildIndexFields(),
$this->buildFormFields(),
$this->buildDetailFields(),
$nestedOrderNotifications,
];
}
...
}
...
class OrderNotification extends Resource
{
...
public function fields(Request $request)
{
return [
BelongsTo::make(__('Order'), 'order', Order::class)
->exceptOnForms(),
Text::make(__('Subject'), 'subject')
->rules('required', 'string'),
Textarea::make(__('Message'), 'message')
->rules('required', 'string')
->alwaysShow()
->hideFromIndex(),
...
];
}
...
}
In the browser
Only the global toasted notification appears, but not in the failed fields.
Having the same issue here, anything new on your side ?
Same here...
Same here
Same here
Same problem here.
Maybe that's happening because the name of the fields aren't the same in the main form and in the subform?
For example, let's suppose I have a resource users
that has a required field named first_name
. In the main resource form the input attribute name will be first_name
, but in an hypothetic subform it will be users[0][first_name]
.
I'm definately not a Vue expert so I'm only assuming.