0

It's easy to configure a Div using the form helper for standard input boxes. An example int he manual is...

    echo $this->Form->input('User.name', array('div' => 'class_name'));

However, I can't achieve the same thing with dropdown menus?

Can anyone help out as to how to wrap a dropdown with a DIV using the form helper method?

thanks

Kieran
  • 2,554
  • 3
  • 26
  • 38

1 Answers1

4

I imagine you've been building your dropdowns with FormHelper::select, which doesn't include all the sugar of FormHelper::input, like automatic <div /> wrapping, magic error-messages, etc. You can get FormHelper::input to output a dropdown using the following.

$this->Form->input(
  'User.country', 
  array(
    'options'=>$arrayOfCountries,
    'div'=>'class_name'
  ) 
);

The options parameter indicates to FormHelper::input that you want a dropdown. You could achieve the same effect with the type parameter (ie. 'type'=>'select'), but the options parameter gives the same effect while also taking care of preparing the dropdown's options.

Daniel Wright
  • 4,584
  • 2
  • 27
  • 28