Placeholder for select field

Hey,

having a select field like this:

  myfile:
    label: Category
    type: select 
    options: files

it preselects the first file that is available for the current page. I would like to have something like select a file as the first entry in the select field. In HTML it would be somethig like

<select>
    <option value="" disabled selected>Select s file</option>
    <option value="file1.pdf">file1.pdf</option>
    <option value="file2.txt">file2.txt</option>
</select>

How would I do this?

Thanks,
Tim

Hm, I’m afraid there is no option for that. I guess you would have to create a custom select field…

If I use the select field it does not select the first available file. Only if I add required: true.

@thguenther Yep you are right. in my (real) example it was required and therefore preselected. Without being required it leaves an empty space. However, it would be nice to be able to define a placeholder text for the empty select option.

Thanks for the help!

I too think it would help the user if there was a placeholder option (as there is with other fields)

Right now I’m trying to adapt this plugin for the Kirby Panel: https://select2.github.io/
That’s why I noticed the required thing immediately.

With this plugin there’s an option to define a placeholder as a data attribute, so it should be very easy to add it as an option in the blueprints. I’m going to publish it when it’s ready, there still are some issues…

I agree this should be an option and created an issue on GitHub.