use Symfony\Component\Form\FormInterface; /** * * Render the total form, just to quickly render a working form * */ Form::macro('render', function (FormInterface $form, Model $model = null) { $view = $form->createView(); $options = array(); $options = array('url' => $view->vars['action'], 'class' => 'form-horizontal'); if ($model) { $html = Form::model($model, $options); } else { $html = Form::open($options); } $html .= Form::renderFields($form); $html .= Form::submit('Save', array('class' => 'btn btn-default')); $html .= Form::close(); return $html; }); /** * * Render only the dynamically generated form fields. * * You have to manually add the Form::open() and Form::close() methods * and add a submit button. * */ Form::macro('renderFields', function (FormInterface $form, $errors = null) { $html = ''; foreach ($form->all() as $child) {