【问题标题】:Cakephp change the Form->input outputCakephp 更改表单->输入输出
【发布时间】:2013-12-13 19:03:29
【问题描述】:

我正在尝试实现输出,其中我有一个包含标签和内部 div 的包装器 div,并且在内部 div 中我有表单输入。

我的输出应该是这样的:

<div class="form-group">
  <label>Name:</label>
  <div class="form-input">
    <input type="text" />
  </div>
</div>

这是我当前在 php 中的表单对象:

echo $this->Form->input('name', array(
    'class' => 'form-input',
    'div' => 'form-group',
    'label' => array('class' => 'control-label')));

但这会将类表单输入添加到实际输入本身。 我怎样才能做到这一点,同时仍然忠实于 CakePHP 的做事方式?

TIA!

【问题讨论】:

    标签: php forms cakephp


    【解决方案1】:

    使用输入选项 'before', 'after', 'between' http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options 我还没有验证它,但我认为它应该看起来像这样:

    echo $this->Form->input('name', array(
        'between' => '<div class="form-input">',
        'after' => '</div>',
        'div' => 'form-group',
        'label' => array('class' => 'control-label')));
    

    【讨论】:

      【解决方案2】:

      这个呢:

      echo $this->Form->input('name', array(
       'div' => 'form-group',
       'before' => '<div class="form-input">',
       'after' => '</div>',
       'label' => array('class'=>'control-label')
      ));
      

      我认为这行得通。

      【讨论】:

      • 感谢您的建议,但我不得不使用“介于”而不是之前
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      相关资源
      最近更新 更多