froala / KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
105 stars 33 forks source link

How to work with Froala inside a form with multiple fields ? #115

Closed AxelBriche closed 4 years ago

AxelBriche commented 4 years ago

Froala autosave don't push all my other fields in the ajax query.

class ThreadType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('title')
            ->add('messages', CollectionType::class, [
                'entry_type' => MessageType::class,
                'entry_options' => [
                    'label' => false
                ],
            ])
            ->add('visible')
            ->add('locked')
            ->add('pinned')
            ->add('send', SubmitType::class, [
                'label' => 'Envoyer',
            ])
        ;
    }
    ...
}
class MessageType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('content', FroalaEditorType::class,[
            'saveURL' => 'thread_create',
            'language' => 'fr',
            'placeholderText' => 'Tapez votre message ici',
            'toolbarInline' => false,
            'attribution' => false,
            'label' => false,
            'pastePlain' => true
        ]);
    }
    ...
}
Capture d’écran 2020-06-05 à 11 35 01 Capture d’écran 2020-06-05 à 11 27 44 Capture d’écran 2020-06-05 à 11 27 26

And inside the query, my "content" field is named "body".

What is the right way to work with froala inside a form with multiple fields please? Thanks.

AxelBriche commented 4 years ago

@jmsche The solution is inside the official doc here but doen't work with this bundle: https://froala.com/wysiwyg-editor/docs/concepts/save/inside-form/

This bundle use textarea but doesn't add all other field in the query.

jmsche commented 4 years ago

You are looking at the wrong part of docs, here they are for autosave: https://froala.com/wysiwyg-editor/docs/concepts/save/autosave/

Not sure why you would expect to receive all fields as the docs state you will get the content of the textarea.

Maybe the saveParams is something you could play with to get other fields.