开发者

CakePHP DIV option for Dropdowns

开发者 https://www.devze.com 2023-02-16 15:31 出处:网络
It\'s easy to configure a Div using the form helper for standard input boxes. An example int he manual is...

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?

t开发者_开发知识库hanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消