No i tak:
Dodałem:
// src/AppBundle/Form/Type/GenderType.php namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; class GenderType extends AbstractType { public function configureOptions(OptionsResolver $resolver) { 'm' => 'Male', 'f' => 'Female', ) )); } public function getParent() { return 'choice'; } public function getName() { return 'gender'; } }
oraz:
{# app/Resources/views/Form/fields.html.twig #} {% block gender_widget %} {% spaceless %} {% if expanded %} <ul {{ block('widget_container_attributes') }}> {% for child in form %} <li> {{ form_widget(child) }} {{ form_label(child) }} </li> {% endfor %} </ul> {% else %} {# just let the choice widget render the select tag #} {{ block('choice_widget') }} {% endif %} {% endspaceless %} {% endblock %}
no config:
twig: form_themes: - 'AppBundle:Form:fields.html.twig'
No i teraz teoretycznie powinno działać.
$form = $this->createFormBuilder($task) ->setAction($this->generateUrl('pagesStore')) ->setMethod('POST') 'placeholder' => 'Choose a gender', )) ->add('task', 'text') ->add('dueDate', 'date') ->getForm();
dostaje błąd:
Neither the property "gender_code" nor one of the methods "getGenderCode()", "genderCode()", "isGenderCode()", "hasGenderCode()", "__get()" exist and have public access in class "AppBundle\Entity\Task
Co może być nie tak?
Już zrobiłem nie dodałem pola w Entity