Skip to content

Select option is not set by default #872

@leecolarelli

Description

@leecolarelli

Found a small issue today when trying to set up a select option on an alpine form... if the x-data for the select x-model is blank, and the form is submitted, then no data for the select form is included.

This seems obvious since the user didn't choose an option, and the x-model/x-data is blank on page load, but often a user will leave a select form if the correct option is already displayed.

Here's a codepen to highlight the issue - https://codepen.io/leecolarelli/pen/PozxLGY

I think therefore that it would be better if alpine has a way to load the displayed option if no selection is made.

I was going to try and make a pull request but don't currently have time, and probably don't have the skills :)

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