2012-04-04 10 views
1

Ich frage mich, warum $this->Form->select() in CakePHP 2.1 kommt nicht mit einer Verpackung div und label.CakePHP - Formular-> Auswählen hat kein Wrapping div?

Muss ich es selbst wickeln haben mag:

<?php 
    echo '<div><label for="MyModel">MyModel</label>'; 
    echo $this->Form->select('MyModel', $options, array('empty' => 'choose one')); 
    echo '</div>'; 
?> 

Antwort

2

Deshalb habe ich jemals nie etwas anderes verwenden als

$this->Form->input(); 

in Ihrem Fall:

$this->Form->input('name', array('type'=>'select', 'empty' => 'choose one', 'options'=>$options)); 

keine Notwendigkeit um jemals auszuwählen(), text() usw.

0
<?php 
echo $this->Form->input('MyModel', array(
     'options' => array(
      'val1' => 'option1', 
      'val2' => 'option2' 
     ) 
     , 
     'empty' => __('choose one'), 
    )); 
?> 

wird das gleiche erreichen