Ejemplo n.º 1
0
 /**
  * RadioSet constructor.
  *
  * @param array|null $options
  * @param string $name
  * @param string|null $value
  * @param string $title
  */
 public function __construct($name, $value = '', $title = '', array $options = null)
 {
     parent::__construct($name, $value, $title);
     $this->options = new ObjectList();
     if (isset($options)) {
         $this->addOptionArray($options);
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public function setValue($value)
 {
     TypeChecker::getInstance()->check($value, [SimpleTypes::STRING, SimpleTypes::ARR, SimpleTypes::BOOL, SimpleTypes::NULL], 'value')->throwTypeErrorIfNotValid();
     if (is_string($value)) {
         parent::setValue(true);
     } else {
         parent::setValue($value);
     }
     return $this;
 }
Ejemplo n.º 4
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()]];
Ejemplo n.º 5
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']);
 }
Ejemplo n.º 6
0
 /** @inheritdoc */
 public function setValue($value)
 {
     parent::setValue($value);
     $this->attributes()->add(new KeyValuePair('value', $value));
     return $this;
 }
Ejemplo n.º 7
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;
 }