add SimpleMdTextareaType::class
This commit is contained in:
parent
559afad7d3
commit
96ea6ed486
|
@ -4,7 +4,7 @@ namespace App\Entity\Page;
|
||||||
|
|
||||||
use App\Core\Entity\Site\Page\Block;
|
use App\Core\Entity\Site\Page\Block;
|
||||||
use App\Core\Entity\Site\Page\FileBlock;
|
use App\Core\Entity\Site\Page\FileBlock;
|
||||||
use App\Core\Form\Site\Page\TextareaBlockType;
|
use App\Form\Type\SimpleMdTextareaBlockType;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
@ -19,12 +19,11 @@ class SimplePage extends TitledPage
|
||||||
|
|
||||||
$builder->add(
|
$builder->add(
|
||||||
'content',
|
'content',
|
||||||
TextareaBlockType::class,
|
SimpleMdTextareaBlockType::class,
|
||||||
[
|
[
|
||||||
'label' => 'Contenu',
|
'label' => 'Contenu',
|
||||||
'options' => [
|
'options' => [
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'data-simplemde' => '',
|
|
||||||
'rows' => '50',
|
'rows' => '50',
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
|
21
src/Form/Type/SimpleMdTextareaBlockType.php
Normal file
21
src/Form/Type/SimpleMdTextareaBlockType.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form\Type;
|
||||||
|
|
||||||
|
use App\Core\Form\Site\Page\TextBlockType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class SimpleMdTextareaBlockType extends TextBlockType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->add(
|
||||||
|
'value',
|
||||||
|
SimpleMdTextareaType::class,
|
||||||
|
array_merge([
|
||||||
|
'required' => false,
|
||||||
|
'label' => false,
|
||||||
|
], $options['options']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
26
src/Form/Type/SimpleMdTextareaType.php
Normal file
26
src/Form/Type/SimpleMdTextareaType.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
|
|
||||||
|
class SimpleMdTextareaType extends TextareaType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
|
{
|
||||||
|
if (!isset($view->vars['attr']['data-simplemde'])) {
|
||||||
|
$view->vars['attr']['data-simplemde'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($view->vars['attr']['rows'])) {
|
||||||
|
$view->vars['attr']['rows'] = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::buildView($view, $form, $options);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue