简体   繁体   中英

Tinymce doesn't work

I implemented the Tinymce's plugin, and it works! In fact, all the text areas now have a text editor. This is my view.

在此处输入图片说明

The problem is that this is obviously a form, and when I submit it, doesn't submit at all.

What could be the problem?

    <?php
// src/AppBundle/Form/RecipeType.php

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

class RecipeType extends AbstractType
{

    protected $currentField;

    protected $entity;

    public function __construct($entity)
    {
        $this->entity = $entity;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder->add('titolo');
        $builder->add('autore');
        $builder->add('tipologia', 'entity', array(
            'class' => 'AppBundle:Tipologia',
            'label' => 'Tipologia',
             'choice_label' => 'name',
        ));
        $builder->add('difficolta','choice',array(
            'choices' => array ('1','2','3','4','5')
        ));
        $builder->add('persone','choice',array(
            'choices' => array ('1','2','3','4','5','6','6+')
        ));
        $builder->add('tempo');
        $builder->add('ingredienti','textarea',array(
            'required' => false,
        ));
        $builder->add('procedimento', 'textarea',array(
            'required' => false,
        ));
        $builder->add('image', 'file', array(
                'data_class' => null,
            'required' => false
            )
        );

          $builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
                    $this->currentField = $this->entity->getImage();
                });

        $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
                    $form = $event->getForm();
                    $inputFile = $form->getData();
                    $newImage = $inputFile->getImage();
                    if (is_null($newImage) && !is_null($this->currentField))
                    {
                        $inputFile->setImage($this->currentField);
                    }
                });
    }

    public function getName()
    {
        return 'recipe';
    }
}

THE SOLUTION: In every Textarea field add required false.

$builder->add('ingredienti','textarea',array(
                'required' => false,
            ));
            $builder->add('procedimento', 'textarea',array(
                'required' => false,
            ));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM