Use CollectionType inside my ThreadType on Symfony display a field for each message, not only the first


class ThreadType extends AbstractType
     * @param FormBuilderInterface $builder
     * @param array $options
    public function buildForm(FormBuilderInterface $builder, array $options)
            ->add('title', TextareaType::class, [
                'attr' => [
                    'class' => 'froala-form-title'
            ->add('messages', CollectionType::class, [
                'label' => false,
                'entry_type' => MessageType::class,
                'entry_options' => [
                    'label' => false
    // ...

My form for create a new Thread is OK, I have my thread title field and the message field:

enter image description here

After that, I add multiple messages inside my thread, and when I want edit my Thread I have this problem:

enter image description here

My CollectionType field display one textarea by messages inside my thread, I only want edit the first message, how can I perform that on Symfony?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *