|
- <?php
-
- namespace Lc\SovBundle\Field;
-
- use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
- use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
- use FOS\CKEditorBundle\Form\Type\CKEditorType;
-
- /**
- * @author Javier Eguiluz <javier.eguiluz@gmail.com>
- */
- final class CKEditorField implements FieldInterface
- {
- use FieldTrait;
-
- public const OPTION_NUM_OF_ROWS = 'numOfRows';
-
- public static function new(string $propertyName, ?string $label = null): self
- {
- return (new self())
- ->setProperty($propertyName)
- ->setLabel($label)
- ->setTemplateName('crud/field/text_editor')
- ->setFormType(CKEditorType::class)
- ->addCssClass('field-text_editor')
- ->setCustomOption(self::OPTION_NUM_OF_ROWS, null);
- }
-
- public function setNumOfRows(int $rows): self
- {
- if ($rows < 1) {
- throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows));
- }
-
- $this->setCustomOption(self::OPTION_NUM_OF_ROWS, $rows);
-
- return $this;
- }
- }
|