choice type symfony
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// ...
$builder->add('isAttending', ChoiceType::class, [
'choices' => [
'Maybe' => null,
'Yes' => true,
'No' => false,
],
]);
choice type symfony
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// ...
$builder->add('isAttending', ChoiceType::class, [
'choices' => [
'Maybe' => null,
'Yes' => true,
'No' => false,
],
]);
creating your own symfony choice type
// src/Form/Type/PostalAddressType.php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class PostalAddressType extends AbstractType
{
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('addressLine1', TextType::class, [
'help' => 'Street address, P.O. box, company name',
])
->add('addressLine2', TextType::class, [
'help' => 'Apartment, suite, unit, building, floor',
])
->add('city', TextType::class)
->add('state', TextType::class, [
'label' => 'State',
])
->add('zipCode', TextType::class, [
'label' => 'ZIP Code',
])
;
}
}
choice type symfony
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// ...
$builder->add('isAttending', ChoiceType::class, [
'choices' => [
'Maybe' => null,
'Yes' => true,
'No' => false,
],
]);
creating your own symfony choice type
// src/Form/Type/PostalAddressType.php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class PostalAddressType extends AbstractType
{
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('addressLine1', TextType::class, [
'help' => 'Street address, P.O. box, company name',
])
->add('addressLine2', TextType::class, [
'help' => 'Apartment, suite, unit, building, floor',
])
->add('city', TextType::class)
->add('state', TextType::class, [
'label' => 'State',
])
->add('zipCode', TextType::class, [
'label' => 'ZIP Code',
])
;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us