An easy way to add empty value to select Field?
An easy way to add empty value to select Field?
I currently have in my server side script:
...
Field::inst( 'ticket.request' )
->options( Options::inst()
->table( 'request' )
->value( 'id' )
->label( 'name' )
->order( 'name ASC' ))
->validator( 'Validate::dbValues', array( 'valid' => array(0) ) ),
...
I want to add to that list of values: {value: 0, label: "Unassigned"} . What's the best way to go about this? Should I do this client side instead? How?
I hope I was clear enough. I'm new >.<
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Rather than doing it on the server-side, do it on the client-side. The
selectfield type has aplaceholderoption which you can use to set an empty value. There are also options such asplaceholderValueand others if you want to allow the placeholder to be submitted to the server (i.e. it might be a null value).Allan
That does the job nicely! Thank you, Allan!