genemu / GenemuFormBundle

Extra Form : Captcha GD, Tinymce, Recaptcha, JQueryDate, JQueryAutocomplete, JQuerySlider, JQueryFile, JQueryImage
587 stars 263 forks source link

[jQuery Rating] Token input rendered as a star #351

Closed Molkobain closed 10 years ago

Molkobain commented 10 years ago

Hi,

when I use the FormType from the bundle, I always have one more star at the end. It's the hidden input token being rendered.

Does anyone else has this issue ?

Here is my test code (PHP) :

$options = array('number' => 5, 'configs' => array('readOnly' => true));

$form = $this->container->get('form.factory')->create(new RatingType(), 2, $options);

return $this->templating->render($name, $parameters + array(
    'ratingForm'  => $form->createView()
));

TWIG :

{{form_widget(ratingForm)}}
{{form_javascript(ratingForm)}}

The result is a 6 stars rating, when hovering the last one, the title is the token value.

Thanks

Molkobain commented 10 years ago

Ok, so I found a way to solve my problem.

It happens because the csrf protection token input has the same name as the rating input. (I guess it because the formtype is not supposed to be used like this) So when the jQuery part applies its magic to all input having the same name, it takes the token too.

What I did to avoid this, was adding an option 'csrf_protection' => false to the formType.

$options = array('number' => 5, 'configs' => array('readOnly' => true), 'csrf_protection' => false);