FAQ
I have two fields in my form, integer and date. Entering letters instead
numbers in first field causes error message to be displayed on both
fields. Is this bug in Symfony or I am doing something wrong?

Here are steps to reproduce it:

Controller:
[code]
public function indexAction(Request $request)
{
$defaultData = array(
'field1' => 1,
'field2' => new \DateTime(),
);

$form = $this->createFormBuilder($defaultData)
->add('field1', 'integer', array(
'label' => 'Enter letters here',
))
->add('field2', 'date', array(
'label' => 'Here should show error',
'input' => 'datetime',
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
))
->getForm();

if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
if ($form->isValid()) {
// Will do something
}
}

return $this->render('SasaTestBundle:Default:index.html.twig',
array(
'form' => $form->createView()
));
}
[/code]

View:
[code]
<form class="form-horizontal" method="post"
action="{{ path('testForm') }}"
{{ form_enctype(form) }}>

{{ form_row(form.field1) }}

{{ form_row(form.field2) }}

{{ form_rest(form) }}

<div class="form-actions">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
[/code]

Routing:
[code]
testForm:
pattern: /test
defaults: { _controller: SasaTestBundle:Default:index }
[/code]

Now, try to enter some letters and instead of number in first field and
then submit. It will show error on both fields.

I am using version v2.0.14.

--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupsymfony-users @
categoriesphp
postedJun 18, '12 at 3:17p
activeJun 18, '12 at 3:17p
posts1
users1
websitesymfony-project.org

1 user in discussion

Sasa Vilic: 1 post

People

Translate

site design / logo © 2018 Grokbase