Creates a dropdown list of states from the US, US Territories and Canada
$options = array( "name" => "thestates", "seperateCountries" => true, "selected" => "VA", ); $htmlOptions = array( "prompt" => "Please select a state", ); echo States::render(array("US","canada","us territories"), $options, $htmlOptions);
Active Form
$form->dropDownList($address, 'state', My_States::getStates(array("US"), true), array('prompt' => 'State', 'class' => 'abc', 'style' => "width:75px;")),
Total 9 comments
Thanks Alan, your changes were added to 1.1
Hi cfletcher1856,
I made the following changes to this extension inorder to 1. allow me to use the states with CActiveForm widgets 2. allow me to generate a drop down of the short-names of the states.
and
With this, I could use the function in a way consistent with the other form element calls:
You could consider adding this to the extension. Thanks, Alan
@oneflatfoot, as of now this just extends the CApplicationComponent and returns CHtml::dropDownList() You can put it in anyform and just deal with the data in the controller. The data will be sent in the post.
Let me know if you need anymore help.
Sorry, but I am a severe noob. How do I put this in my form? Is it a $form->dropDownList? If so, does the usage code go in the CHtml::listData section? Thanks.
My question is do I store this in database as varchar or text, enum?
Got it to work :-) It was simple . Thank you for the quick response and awesome extension..
Hi Ruaan,
Did you not see the install and usage sections above?
What problems are you running into?
@dungdeveloper, I'm glad that the extension helped you out.
How do I use this extension ?
Thanks for your extension. It helps me alot!
Leave a comment
Please login to leave your comment.