Skip to content

Instantly share code, notes, and snippets.

@syrm
Last active August 29, 2015 14:12
Show Gist options
  • Save syrm/105b514416e79ec78ceb to your computer and use it in GitHub Desktop.
Save syrm/105b514416e79ec78ceb to your computer and use it in GitHub Desktop.
Problem generate custom choice_widget
{% block choice_widget %}
{% for child in form %}
{{ form_widget(child) }}
{% endfor %}
{% endblock %}
<?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';
}
}
<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