Catch Symfony Form Errors
Have you built a form while developing with the symfony form framework that appears to work fine but fails because of an unknown error? Here is the simplest and easiest way to catch most errors.
First open the web page with the form and fill it in with valid input. Then, open the form php file, temporarily delete all your custom form render code and replace it with echo $form. Go back to the web page and click your form submit button. It should show you any validation errors that appear in the form but were missing on your customized version, because this time it’s rendering the form with the default settings. At the very least it could show you something you missed and hint at the solution.
Your test form would look like this:
<form action="<?php echo url_for('user/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<table>
<tfoot>
<tr>
<td>
<?php echo $form->renderHiddenFields() ?>
<input type="submit" value="Save">
</td>
</tr>
</tfoot>
<tbody>
<?php echo $form ?>
</tbody>
</table>
</form>


February 17th, 2011 at 12:55 pm
Even with 1.43, I had a problem where I couldn’t figure out a form error and this technique helped me figure it out. Thanks.
October 11th, 2011 at 10:40 am
good tip – sometime just reverting to defaults can give you the clue as to what the problem is.