Beispiel #1
0
 /**
  * @param string $name
  * @param string $title
  *
  * @throws ArgumentTypeException
  */
 function __construct($name, $title = '')
 {
     $this->attrs = new NamedObjectList([KeyValuePair::getClass()]);
     $this->children = new NamedObjectList([Block::getClass(), AbstractField::getClass()]);
     parent::__construct($name);
     $this->title($title);
     $this->isValid = true;
     $this->templateName = self::DEFAULT_TEMPLATE;
 }
Beispiel #2
0
<?php

/**
 * User: Ionov George
 * Date: 17.03.2016
 * Time: 9:06
 */
return ['renderer' => ['templates' => ['default' => ['form' => '{result}{errors}{label}<div>{start}{children}{handlers}{end}</div>{scripts}', 'block' => '{label}<div>{children}</div>', 'field' => '<div><label {forField}>{title}</label>{field}</div>{errors}', 'handler' => '<div>{handler}</div>', 'errors' => ['default' => '<span>{errorsStr}</span>', 'form' => '<div>{errorsStr}</div>'], 'label' => ['default' => '<span>{title}</span>', 'form' => '<div>{title}</div>'], 'result' => '<div class="{className}">{message}</div>', 'checkSet' => '{label}<div>{options}</div>{errors}', 'checkSetOption' => '<span><label>{optionTitle}{option}</label></span>', 'repeatFiled' => '<div {blockSelector}>{field}{actions}{errors}</div>', 'repeatBlock' => '<div {blockSelector}>{children}{actions}</div>', 'repeatContainer' => '<div {containerSelector}>{label}{children}</div>{repeatScript}', 'repeatActionsBlock' => '<div {actionsBlockSelector}="{name}">{deleteButton}{addButton}</div>', 'deleteButton' => '<span {deleteActionSelector}>-</span>', 'addButton' => '<span {addActionSelector}>+</span>', 'attribute' => '{name}="{value}"', 'shortAttribute' => '{name}']], 'repeat' => ['block' => 'data-repeat-block', 'container' => 'data-repeat-container', 'actionsBlock' => 'data-repeat-actions', 'deleteAction' => 'data-delete', 'addAction' => 'data-add'], 'errors' => ['delimiter' => '<br>'], 'alias' => [\NewInventor\Form\Form::getClass() => 'form', \NewInventor\Form\Block::getClass() => 'block', \NewInventor\Form\Field\AbstractField::getClass() => 'field', \NewInventor\Form\Handler::getClass() => 'handler']], 'validator' => ['email' => \NewInventor\Form\Validator\Validators\EmailValidator::getClass(), 'integer' => \NewInventor\Form\Validator\Validators\IntegerValidator::getClass(), 'string' => \NewInventor\Form\Validator\Validators\StringValidator::getClass(), 'required' => \NewInventor\Form\Validator\Validators\RequiredValidator::getClass()]];
Beispiel #3
0
 /**
  * AbstractForm constructor.
  *
  * @param string $name
  * @param string $title
  * @param string $action
  * @param string $method
  * @param string $encType
  *
  * @throws ArgumentException
  * @throws ArgumentTypeException
  */
 public function __construct($name, $action = '', $method = 'post', $title = '', $encType = self::ENC_TYPE_URLENCODED)
 {
     parent::__construct($name, $title);
     if (!is_null($action)) {
         $this->action($action);
     }
     if (!is_null($method)) {
         $this->method($method);
     }
     if (!is_null($encType)) {
         $this->encType($encType);
     }
     $this->handlers = new NamedObjectList();
     $this->handlers->setElementClasses(['NewInventor\\Form\\Interfaces\\HandlerInterface']);
     $this->children()->setElementClasses([Block::getClass(), AbstractField::getClass()]);
     $defaultData = (include __DIR__ . '/config/default.php');
     $this->addDefaultConfig('renderer', $defaultData['renderer']);
     $this->addDefaultConfig('validator', $defaultData['validator']);
 }
Beispiel #4
0
 /**
  * @inheritdoc
  */
 public function repeatable($object)
 {
     TypeChecker::getInstance()->check($object, [Block::getClass(), AbstractField::getClass()], 'object')->throwTypeErrorIfNotValid();
     $repeatableBlockName = $object->getName();
     $repeatableBlockTitle = $object->getTitle();
     $object->title('');
     $repeatableBlock = new Block($repeatableBlockName, $repeatableBlockTitle);
     $repeatableBlock->setRepeatable(true);
     $object->setName('#IND#');
     $repeatableBlock->setRepeatObject($object);
     $deepCopy = new DeepCopy();
     $objectClone = $deepCopy->copy($repeatableBlock->getRepeatObject());
     $objectClone->setParent($repeatableBlock);
     $objectClone->setName('0');
     $repeatableBlock->children()->add($objectClone);
     $repeatableBlock->setParent($this);
     $this->children()->add($repeatableBlock);
     return $this;
 }