Skip to content

Cannot validate a MultiSelect field #6248

@dominik-eller

Description

@dominik-eller
  • Laravel Version: 10.46
  • Nova Version: 4.27
  • PHP Version: 8.3
  • Database Driver & Version: MYSQL
  • Operating System and Version: MAC OS Sonoma 14.2.1
  • Browser type and version: Safari 17.2.1
  • Reproduction Repository: -/-

Description:

I am trying to make a MultiSelect field required and I ended up using something like that:

MultiSelect::make('reason')->options([
            'Option A' => 'Option A',
            'Option B' => 'Option B',
            'Option C' => 'Option C',
        ])->rules('required', 'array', 'min:1'),

I also tried to use 'in:Option A,Option B,Option C' but it is not working.

I am casting the reason property to array as suggested in the documentation, but the validation message always returns "The reason field must be an array."

Detailed steps to reproduce the issue on a fresh Nova installation:

  • add a MultiSelect field to a nova resource
  • add a cast to array to that property
  • add a validation to the field

even just using ->rules('required') is not working for MultiSelect field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions