0
votes

I want to group the form fields like field set or simply enclosed by div. My form needs to be look like below

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

Graphical example :

Edit : Form class added for reference!

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

How can I do this in symfony form?

1
@j0k: My Form template is default _from.php file. Is that possible do it from configure() function.Gowri
Ok, and can we see the form class? Since it seems that you have an embed form.j0k
@j0k: add form class in my postGowri

1 Answers

2
votes

For example:

In action:

$this->form = new MyCoolForm()

In templates:

<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...