Category: formbuilder

How can I get only specific elements of an entity with Symfony formbuilder?

In my formbuilder I create a select box from an entity: $options[‘choice_label’] = function ( $entity) use ($name) { if( $entity->getCategory() == null) { return $entity->getName(); } }; In the case the Category is NULL, I want to get an…

Expected type ‘SymfonyComponentFormFormInterface’. Found ‘null’

I want to add a field "subCategories" in a form wich should appear when a Category is selected. Here is my formType: <?php namespace AppForm; use AppEntityCategories; use AppEntityKeywords; use DoctrineORMEntityRepository; use SymfonyBridgeDoctrineFormTypeEntityType; use SymfonyComponentFormAbstractType; use SymfonyComponentFormExtensionCoreTypeTextType; use SymfonyComponentFormFormBuilderInterface; use…

How to retrieve Entity instance of an EntityType field inside a twig template in Symfony

I am currently experiencing a problem with recovering the data I need, and I really hope that you will be able to help me. I am trying to create a form via the Symfony formbuilder to create an object that…

I have username which is type string in entity User, but in form builder i dont have String type. How can i fix that? [closed]

public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(‘username’, TextType::class, array(‘label’ => ‘Username: ‘, ‘attr’=>array(‘class’=>’form-control mb-3’))) } and i get error “Could not load type “AppFormTextType”: class does not exist.” Source: Symfony Questions

symfony form field’s required (*) flag ignores validation groups

I’m using entity @Assert annotations with different groups tags. /** * @var string * @AssertNotBlank(groups={“basic”}) * @ORMColumn(name=”name”, type=”string”, length=255, nullable=true) */ private $name = null; /** * @var string * @AssertNotBlank(groups={“advanced”}) * @ORMColumn(name=”full_name”, type=”string”, length=255, nullable=true) */ private $fullName =…

Symfony form builder: How to iterate/render dynamic amount of text fields in twig? (Sylius – exta checkout step)

I added an extra checkout step to the Sylius checkout procedure and I am trying to add 1 text field per instance of an ordered item. Thus having put 3x itemA and 1x itemB in cart should spawn 4 text…

Symfony CreateFormBuilder ignores my Entity @AssertLength

I have an entity User, which has $password with @AssertLength(min=6) /** * @var string The hashed password * @ORMColumn(type=”string”) * @AssertLength( min=6, minMessage=”Password is too short (min 6 symbols)” ) */ private $password; I’m trying to generate a Login form…