blackknight467 / StarRatingBundle

star rating bundle for symfony
MIT License
26 stars 40 forks source link

problem #17

Closed hamzarebaichkaw closed 7 years ago

hamzarebaichkaw commented 7 years ago

An exception has been thrown during the rendering of a template ("Notice: Object of class Symfony\Component\Form\FormView could not be converted to int")

hamzarebaichkaw commented 7 years ago

"exception" => Twig_Error_Runtime {#1601 ▼ -lineno: 3 -name: "StarRatingBundle:Display:ratingDisplay.html.twig" -rawMessage: "An exception has been thrown during the rendering of a template ("Notice: Object of class Symfony\Component\Form\FormView could not be converted to int")." -sourcePath: "/var/www/html/MMSS/vendor/blackknight467/star-rating-bundle/blackknight467/StarRatingBundle/Resources/views/Display/ratingDisplay.html.twig" -sourceCode: """

\n {% for i in 1..max %}\n
\n {% endfor %}\n
""" #message: "An exception has been thrown during the rendering of a template ("Notice: Object of class Symfony\Component\Form\FormView could not be converted to int")." #code: 0 #file: "/var/www/html/MMSS/vendor/blackknight467/star-rating-bundle/blackknight467/StarRatingBundle/Resources/views/Display/ratingDisplay.html.twig" #line: 3
blackknight467 commented 7 years ago

@hamzarebaichkaw can you post the twig you're using and the value of the variable you're passing to the rating filter?

hamzarebaichkaw commented 7 years ago

{{ form_start(commentaire, {'action': path('AjoutCommentaire') , 'method': 'POST','class':'comment-form'}) }}

{{ form_widget(commentaire.comment, { 'attr': {'class': 'form-control','cols':'45','rows':'8', 'placeholder': 'Write your comment here...'} }) }}

{{ form_widget(commentaire.rating|rating(5,"fa-3x") ) }}

{{ form_end(commentaire) }}

blackknight467 commented 7 years ago

@hamzarebaichkaw is "commentaire.rating" a string or an int?

hamzarebaichkaw commented 7 years ago

int

blackknight467 commented 7 years ago

@hamzarebaichkaw oh, you're trying to use a filter in your form. Just remove the rating filter and you should be fine.

{{ form_widget(commentaire.rating) }}
hamzarebaichkaw commented 7 years ago

@blackknight467 thank you it worked