Category: symfony-forms

symfony collection type form field with linking to existing object and allowing new objects

Dont know how this field is called correctly But is there a simple way to add collection type field with an option to select existing records and posibility to add new records and delete records from entity? Basically a want…

Symfony 4 quiz style form, embedded collection types

I’m trying to display a quiz style form where end-user gets presented with questions that can have one or multiple correct answers. Entities: Exam Question <?php namespace AppEntity; use DoctrineCommonCollectionsArrayCollection; use DoctrineCommonCollectionsCollection; use DoctrineORMMapping as ORM; use GedmoTimestampableTraitsTimestampableEntity; use RamseyUuidUuidInterface;…

Expected argument of type "string", "null" given at property path

Actually when I try to edit the form by sending empty fields, the above error comes on , My UserType class looks like: class UserType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(‘firstName’, null, [ ‘label’…

Cannot read index "type" from object of type "stdClass" because it doesn’t implement ArrayAccess

I am getting this error on this if ($this->container->getParameter(‘sso.so’) === true) { $builder->add(‘familyMembers’, CollectionType::class, array( ‘type’ => new FamilyMember(), ‘allow_add’ => TRUE, ‘allow_delete’ => TRUE, ‘by_reference’ => FALSE, )); $builder->get(‘familyMembers’)->setData(array()); } this is the form Type class FamilyMember extends AbstractType…

How to display a semi-related entity in Symfony Forms

I have following entities: class Track { /** * @ORMId() * @ORMGeneratedValue() * @ORMColumn(type=”integer”) */ private $id; /** * @ORMColumn(type=”string”, length=255) */ private $title; /** * @ORMOneToMany(targetEntity=”AppEntityPlaylistTrack”, mappedBy=”track”) */ private $playlistTracks; … } class PlaylistTrack { /** * @ORMId() *…