ChoiceType example

use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Test\FormIntegrationTestCase;

class FormExtensionFieldHelpersTest extends FormIntegrationTestCase
{
    private FormExtension $rawExtension;
    private FormExtension $translatorExtension;
    private FormView $view;

    protected function getTypes()
    {
        return [new TextType()new ChoiceType()];
    }

    protected function setUp(): void
    {
        parent::setUp();

        $this->rawExtension = new FormExtension();
        $this->translatorExtension = new FormExtension(new StubTranslator());

        $data = [
            'username' => 'tgalopin',
            
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
        $this->choiceListFactory = $choiceListFactory ?? new CachingFactoryDecorator(new PropertyAccessDecorator(new DefaultChoiceListFactory()$this->propertyAccessor));
        $this->translator = $translator;
    }

    protected function loadTypes(): array
    {
        return [
            new Type\FormType($this->propertyAccessor),
            new Type\BirthdayType(),
            new Type\CheckboxType(),
            new Type\ChoiceType($this->choiceListFactory, $this->translator),
            new Type\CollectionType(),
            new Type\CountryType(),
            new Type\DateIntervalType(),
            new Type\DateType(),
            new Type\DateTimeType(),
            new Type\EmailType(),
            new Type\HiddenType(),
            new Type\IntegerType(),
            new Type\LanguageType(),
            new Type\LocaleType(),
            new Type\MoneyType(),
            
$options['core_types'] = [];
        $options['service_types'] = [FooType::class];
        $options['show_deprecated'] = true;
        yield [null, $options, 'types_with_deprecated_options'];
    }

    public static function getDescribeResolvedFormTypeTestData()
    {
        $typeExtensions = [new FormTypeCsrfExtension(new CsrfTokenManager())];
        $parent = new ResolvedFormType(new FormType()$typeExtensions);

        yield [new ResolvedFormType(new ChoiceType()[]$parent)['decorated' => false, 'show_deprecated' => false], 'resolved_form_type_1'];
        yield [new ResolvedFormType(new FormType())['decorated' => false, 'show_deprecated' => false], 'resolved_form_type_2'];
        yield [new ResolvedFormType(new FooType()[]$parent)['decorated' => false, 'show_deprecated' => true], 'deprecated_options_of_type'];
    }

    public static function getDescribeOptionTestData()
    {
        $parent = new ResolvedFormType(new FormType());
        $options['decorated'] = false;
        $options['show_deprecated'] = false;

        $resolvedType = new ResolvedFormType(new ChoiceType()[]$parent);
        
Home | Imprint | This part of the site doesn't use cookies.