PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 6, 2024
Let's talk code, commerce and open source.

Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

YesAndNoChoiceType

The YesAndNoChoiceType represents select input with options Yes and No.

Type options

Option Type Default Description
choices array array By default Yes/No choices are defined
required boolean false Whether field is required or not

Required Javascript components

None.

Code example

Add YesAndNoChoiceType to your form.

<?php

use Symfony\Component\Form\AbstractType;
use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType;

class SomeType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('yesandnochoicetype', YesAndNoChoiceType::class, [
            'choices' => [
                'Yes' => true,
                'No' => false,
            ],
        ]);
    }
}

Preview example

YesAndNoChoiceType rendered in form