Select Box Options - Allow extra field of NULL
Select Box Options - Allow extra field of NULL
mRender
Posts: 151Questions: 26Answers: 13
Right now with my current set up I have:
Field::inst( 'tbl_Controller.MID' )
->options( 'tbl_Models', 'MID', 'model_no' ),
{
label: "Model:",
name: "tbl_Controller.MID",
type: "select"
},
Everything works great with this.
But what if, at the time of creating or editing, I don't want a value in this field.
I would almost want something like this:
Field::inst( 'tbl_Controller.MID' )
->options( '', '(NULL)', '' ),
->options( 'tbl_Models', 'MID', 'model_no' ),
Any additions I've tried to make to this field results in ->options( 'tbl_Models', 'MID', 'model_no' ), being in the select box list.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
Field->options()
method when passed three strings, as documented, will make a request to the database based on the parameters given. If you want to add an option you have two options:Editor->data()
method and then do something like$data['options']['tbl_Controller.MID'][] = array( ... );
.Field->options()
with a closure function where you defined what data will be shown in the list.Allan