Select lists
Select lists
I have a couple of questions re select lists using editor
- Order of labels from a recordset
As an example, i have this syntax in my ajax page
$data['refitemtype'] = $db
->selectDistinct( 'refitemtype', 'ItemTypeID as value, ItemTypeDescription as label' )
->fetchAll();
}
Is there a way I can set the ORDER of the select labels without resorting to a view ?
- Is it possible to add a static option to the top of the list, without a value, saying something like 'please choose an option from the list' rather than having the first row displayed ?
Thnaks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Certainly - the
selectDistinct
method has an optional order option as the fourth parameter.You could modify the
$data['refitemtype']
array once it has been retrieved andunshift
the "Please select..." text to it. You would also need to make sure your field validator will reject the default value!Allan
re 1) How do I skip the 3rd parameter ?
I tried double comma, quotes etc but get a syntax error.
eg if I want to order by sizedescription
Just put in
null
:-)Allan
well maybe its me, but that gives me a json error
for example, if I try
i get
Odd. Could you try:
please?
Allan
Sorry, that gives me the same error
Ah - sorry, you are missing the direction specified for the order clause that I had in my post above. I know it isn't always required in SQL, but the Editor libraries do need it:
Allan
edit - reformatted the code to make it clearer).
cool, that's it.
(Also works with the original field name, as well as the label alias)