Esempio n. 1
0
 private function resetLabel(AbstractField $field)
 {
     if ($field->getId()) {
         $field->generateId();
         $field->getLabel()->setFor($field->getId());
     }
 }
Esempio n. 2
0
 /**
  * @param string $name
  * @param string $label
  * @param array $values
  */
 public function __construct(string $name, string $label = null, array $values = [])
 {
     parent::__construct('<input />', $name, $label);
     $this->getField()->addAttribute('type', 'hidden');
     $this->getField()->setRenderable(false);
     $this->addClass('form-group cawa-fields-button-group');
     $this->values = $values;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function setValue($value) : parent
 {
     if ($value instanceof DateObject || $value instanceof DateTimeObject) {
         $value = $value->format('Y-m-d\\TH:i:s');
     } elseif (is_string($value) && $value) {
         $date = new DateTimeObject($value);
         $value = $date->format('Y-m-d\\TH:i:s');
     }
     return parent::setValue($value);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function setValue($value) : parent
 {
     if ($value instanceof TimeObject) {
         $value = $value->format();
     } elseif (is_string($value) && $value) {
         $date = new TimeObject($value);
         $value = $date->format();
     }
     return parent::setValue($value);
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function __construct(string $name = null, string $label = null)
 {
     if (is_null($label)) {
         self::translator()->addFile(__DIR__ . '/../../../lang/global', 'bootstrap');
         $label = self::trans('bootstrap.creditcard/expiration');
     }
     parent::__construct('<input />', $name, $label);
     $this->getField()->addAttribute('type', 'text');
     $this->getField()->addClass('form-control');
     $this->addClass('form-group');
     $this->setPlaceholder(self::trans('bootstrap.creditcard/expirationPlaceholder'));
     $this->getField()->addClass('cawa-fields-creditcard-expiry cc-exp');
     $this->getField()->addAttribute('autocomplete', 'cc-exp');
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function __construct(string $name = null, string $label = null)
 {
     if (is_null($label)) {
         self::translator()->addFile(__DIR__ . '/../../../lang/global', 'bootstrap');
         $label = self::trans('bootstrap.creditcard/cvv');
     }
     parent::__construct('<input />', $name, $label);
     $this->getField()->addAttribute('type', 'text');
     $this->getField()->addClass('form-control');
     $this->addClass('form-group');
     $this->getField()->addClass('cawa-fields-creditcard-cvc cc-cvc');
     $this->getField()->addAttribute('autocomplete', 'off');
     $this->getField()->addAttribute('size', '4');
 }
Esempio n. 7
0
 /**
  * @return string
  */
 public function render()
 {
     if ($this->isRequired() == true || $this->isMultiple() == true) {
         if (!is_null($this->getValue())) {
             $this->optionsElements['']->setRenderable(false);
         }
     }
     return parent::render();
 }
 /**
  * @param AbstractField|BootstrapPropertiesTrait $element
  */
 protected function applySize($element)
 {
     if (!$element->getFieldSize()) {
         return;
     }
     if ($this instanceof Submit) {
         $this->getField()->addClass($element->getFieldSize() == Form::SIZE_LARGE ? 'btn-lg' : 'btn-sm');
     } else {
         if ($this->horizontal) {
             $this->addClass($element->getFieldSize() == Form::SIZE_LARGE ? 'form-group-lg' : 'form-group-sm');
         } else {
             $this->getField()->addClass($element->getFieldSize() == Form::SIZE_LARGE ? 'input-lg' : 'input-sm');
         }
     }
 }
Esempio n. 9
0
 /**
  * @param $filter
  *
  * @return $this|self
  */
 public function addFilter(AbstractField $filter) : self
 {
     if (!$this->filtersForm) {
         $this->filtersForm = new Form();
         $this->filtersForm->setMethod('GET')->setName($this->stateId ? $this->stateId : 'grid')->setAction(self::request()->getUri()->get());
         $this->navbar->add($this->filtersForm);
     }
     if ($this->stateId) {
         $filter->setName($this->stateId . '_' . $filter->getName());
     }
     $this->filtersForm->add($filter);
     $this->filtersForm->setAction(Uri::parse($this->filtersForm->getAction())->removeQuery($filter->getName())->get());
     if ($filter->getLabel()) {
         $filter->getLabel()->addClass('sr-only');
     }
     return $this;
 }
Esempio n. 10
0
 /**
  * @param AbstractField|Group|Fieldset $element
  *
  * @return void
  */
 private function addErrorClass($element)
 {
     if ($element instanceof Group || $element instanceof Fieldset) {
         foreach ($element->getFields() as $field) {
             if ($element instanceof Group || $element instanceof Fieldset) {
                 $this->addErrorClass($field);
             } elseif ($field->isRequired()) {
                 $field->addClass('has-error');
             }
         }
     } elseif ($element->isRequired()) {
         $element->addClass('has-error');
     }
 }
Esempio n. 11
0
 /**
  * @param string $name
  * @param string $label
  */
 public function __construct(string $name, string $label = null)
 {
     parent::__construct('<input />', $name, $label);
     $this->getField()->addAttribute('type', 'file');
 }
Esempio n. 12
0
 /**
  * @param AbstractField|Group|Fieldset $element
  * @param mixed $userInput
  *
  * @return array
  */
 private function validateValue($element, $userInput) : array
 {
     $valid = true;
     $value = null;
     $typedValue = null;
     if ($element->isRequired() && is_null($userInput)) {
         $valid = false;
     }
     if ($element->getPrimitiveType() && !is_null($userInput)) {
         $typedValue = $this->validateType($userInput, $element->getPrimitiveType());
         if (is_null($typedValue)) {
             $valid = false;
         } else {
             $value = $typedValue;
         }
     } else {
         $value = $userInput;
     }
     if (method_exists($element, 'isValid') && $valid == true && $element->getValue()) {
         $valid = $element->isValid();
     }
     if (!$valid) {
         $value = null;
     }
     return [$valid, $value, $typedValue];
 }