php - Zend Framework - Set 'selected' value in select box dropdown list -
I am adding a selected element for a Zend_Form example as follows:
$ user = $ Form-> Create Element ('Select', 'Users') - & gt; Set label ('user:') - & gt; Setuped (true); Foreign Currency ($ US $ as user) {if ($ selected == $ u- & gt; ID) {$ user- & gt; Addition of the selected option = "selected"} and the $ user- ($ u-> ID, $ u- & gt; first name.) ". $ U- & gt; lastname; & Gt; Add multi-option ($ u- & gt; id, $ u- & gt; first name. '' $ U- & gt; last name);}
I'm looking for docs But in 'Selected' one can not find an easy way to pre-set one of the selected elements.
I have just worked on how to do it.
Use the setValue () method:
$ user = $ form-> Create element ('select', 'user') -> Set labels ('User: ') - & gt; Setuped (true); Foreign currency ($ U as user $) $ user- & gt; ad multipation ($ U-> ID, $ U- & gt; first name.). $ U- & gt; Last name); $ user- & gt; setValue ($ selected); $ $ is selected & lt; option & gt; s 'value' that you want to apply to selected = "selected"
Comments
Post a Comment