2

I have a form with a drop down that has a list of states set like this.

$this->addfield('State','state')->setValueList(array('Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming')); 

I want the dropdown to default to New York. How can this be done in agile toolkit?

Michael
  • 701
  • 6
  • 18
Ralanyo
  • 61
  • 9
  • I recommend you to use `->enum(array('..'))` instead of setValueList, then your database will contain the states , not the numbers. – romaninsh Dec 31 '12 at 03:49

1 Answers1

1

have you tried chaining

->defaultValue('New York')

?

http://agiletoolkit.org/doc/modeltable/fields

freethejazz
  • 2,235
  • 14
  • 19
  • Thanks.That worked. I missed that on the documentation. I originally didn't have 'New York' => 'New York' in my list values so it was pulling the first one it found. – Ralanyo Dec 31 '12 at 03:02