2016-09-06 65 views
-1

如何產生使用CakePHP的形式幫助下面的HTML:CakePHP的2表單輔助

<div class="form-group"> 
 
<label for="input-Default" class="col-sm-2 control-label">Default</label> 
 
<div class="col-sm-10"> 
 
<input type="text" class="form-control" id="input-Default"> 
 
</div> 
 
</div>

感謝你需要

回答

0

一切都是在HTML幫手。

echo $this->Html->div('form-group', 
    $this->Html->tag('label', 'Default', 
     array(
      'for' => 'input-Default', 
      'class' => 'col-sm-2 control-label', 
     ) 
    ) . 
    $this->Html->div('col-sm-10', 
     $this->Form->input('', 
      array(
       'type' => 'text', 
       'class' => 'form-control', 
       'id' => 'input-Default', 
       'div' => false, 
       'label' => false 
      ) 
     ) 
    ) 
); 

http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html