0

我想对表单字段进行分组,例如字段集或简单地由 div 包围。我的表格需要如下所示

<form>
<div class="step-1">
    Field 1
    Field 2
</div>
<div class="step-2">
    Field 3
    Field 4
</div>
</form>

图形示例:

编辑:添加表单类以供参考!

class ProfileForm extends BaseProfileForm
{
  public function configure()
  {
    ..... // other widget configuration
    $this->embedForm('media', new MediaForm());
  }
}

我怎样才能以 symfony 的形式做到这一点?

4

1 回答 1

2

例如:

在行动:

$this->form = new MyCoolForm()

在模板中:

<form name="form name" id="MyCoolForm" action="<?php echo url_for('action_url') ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>

 <?php echo $form['name']->render() ?>
 <?php echo $form['name']->renderError(); ?>

 <fieldset>
  <legend>Ppassword:</legend>
 <?php echo $form['password']->render() ?>
 <?php echo $form['password']->renderError(); ?>

 <?php echo $form['password_again']->render() ?>
 <?php echo $form['password_again']->renderError(); ?>
<fieldset>

 <?php echo $form->renderHiddenFields(); ?>
</form>

ETC...

于 2012-11-21T15:58:44.433 回答