Skip to content

No validation error when submitting a required select component with an empty option #329

@rbarreca

Description

@rbarreca

It's probably just user error, but I can't figure out how to make a required select component with an empty option. It doesn't trigger any Polaris validation, rather just gets to the Rails controller and errors out with undefined method map' for nil:NilClass`.

I've tried adding [''] or [['', '']] or [['', nil]] to @options_from_controller, but none of them do the trick. What am I doing wrong?

<%= polaris_select(name: 'vendor_product_setting[foo_id]', 
              label: "Infoplus vendor",
              options: @options_from_controller, 
              required: true, selected: @vendor_product_setting.foo_id) %>

The example for required doesn't have an empty option which makes it not useful.

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