[英]Tinymce doesn't work
I implemented the Tinymce's plugin, and it works! 我实现了Tinymce的插件,并且有效! 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. 解决方案:在每个Textarea字段中添加必填false。
$builder->add('ingredienti','textarea',array(
'required' => false,
));
$builder->add('procedimento', 'textarea',array(
'required' => false,
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.