laravel-nova-nested-form icon indicating copy to clipboard operation
laravel-nova-nested-form copied to clipboard

Validation messages are not displayed

Open iBet7o opened this issue 4 years ago • 5 comments

  • 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

image

Only the global toasted notification appears, but not in the failed fields.

iBet7o avatar Jun 18 '20 00:06 iBet7o

Having the same issue here, anything new on your side ?

GautierDele avatar Nov 24 '20 15:11 GautierDele

Same here...

lopandpe avatar Feb 03 '21 07:02 lopandpe

Same here

Casperhr avatar Mar 09 '21 08:03 Casperhr

Same here

aswin-ghosh-chenattil avatar Sep 01 '21 16:09 aswin-ghosh-chenattil

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.

MarDenDev avatar Mar 21 '22 14:03 MarDenDev