Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation messages are not displayed #104

Open
iBet7o opened this issue Jun 18, 2020 · 5 comments
Open

Validation messages are not displayed #104

iBet7o opened this issue Jun 18, 2020 · 5 comments

Comments

@iBet7o
Copy link

iBet7o commented Jun 18, 2020

  • 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.

@GautierDele
Copy link

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

@lopandpe
Copy link

lopandpe commented Feb 3, 2021

Same here...

@Casperhr
Copy link

Casperhr commented Mar 9, 2021

Same here

1 similar comment
@aswin-ghosh-chenattil
Copy link

Same here

@MarDenDev
Copy link

MarDenDev commented Mar 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants