-
-
Save syrm/105b514416e79ec78ceb to your computer and use it in GitHub Desktop.
Problem generate custom choice_widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% block choice_widget %} | |
{% for child in form %} | |
{{ form_widget(child) }} | |
{% endfor %} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
class CommentType extends AbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('content', 'text'); | |
$builder->add( | |
'rating', | |
'choice', | |
[ | |
'choices' => [1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5], | |
'expanded' => true, | |
'multiple' => false | |
] | |
); | |
$builder->add('spoiler', 'checkbox'); | |
} | |
public function getName() | |
{ | |
return 'comment'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="radio"> | |
<label class="required"> | |
<input type="radio" id="comment_rating_0" name="comment[rating]" required="required" value="1"> | |
1 | |
</label> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment