An easy way to add empty value to select Field?

An easy way to add empty value to select Field?

KyKy Posts: 6Questions: 2Answers: 0
edited July 2017 in Free community support

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

Answers

  • allanallan Posts: 63,893Questions: 1Answers: 10,531 Site admin
    Answer ✓

    Rather than doing it on the server-side, do it on the client-side. The select field type has a placeholder option which you can use to set an empty value. There are also options such as placeholderValue and others if you want to allow the placeholder to be submitted to the server (i.e. it might be a null value).

    Allan

  • KyKy Posts: 6Questions: 2Answers: 0

    That does the job nicely! Thank you, Allan!

This discussion has been closed.