I using symfony 1.4.8 and when trying to render the hidden csrf form field a value is not being added to the rendered field. I’ve done this before without issue. See the following to examples below to see the code and the rendered output.
Code:
<?php echo $form['_csrf_token']->render(); ?>
Generates:
<input type="hidden" name="contact[_csrf_token]" id="contact__csrf_token" />
Code:
<?php echo $form['_csrf_token']->renderRow(); ?>
Generates:
<tr>
<th><label for="contact__csrf_token"> csrf token</label></th>
<td><input type="hidden" name="contact[_csrf_token]" value="3cf960d4553e2649f86d0ccd12a26efe" id="contact__csrf_token" /></td>
</tr>
As you can see the second method generates the value for the csrf_token, but it also generates all the other row information. The render() method is supposed to just generate the ‘widget’ (in this case the hidden input field) with the value. For some reason it does not add a value.
Why do you need to explicitly render it? Why are you not using
$form->renderHiddenFields()?