/** * Return the Input Attributes * @return array */ public function inputAttributes() { $attr = parent::inputAttributes(); $attr['min'] = '0.01'; $attr['step'] = '0.01'; $attr['max'] = '999999999'; return $attr; }
/** * Return the Wrapper Attributes * @return array */ public function wrapperAttributes() { $attr = parent::wrapperAttributes(); if (!empty($this->_inputPrepend) || !empty($this->_inputAppend)) { $attr['class'][] = 'span2'; } return $attr; }
public function getValue() { $value = parent::getValue(); if (is_string($value)) { $value = zbase_date_from_format($this->getDateFormat(), $value); } if ($value instanceof \DateTime) { $this->_value = $value->format($this->getDateFormat()); } return $this->_value; }
/** * Create an element * @param array $element Element configuration * @param string $tabName The tabName the element belongs * @return Zbase\Ui\Form\ElementInterface */ protected function _createElement($element, $tabName = null) { $e = \Zbase\Ui\Form\Element::factory($element); if (is_null($e)) { return; } $e->setAttribute('widgetEntity', $this->entity()); if ($e instanceof \Zbase\Widgets\Type\FormInterface) { $e->form($this); if (empty($this->_entityIsDefault)) { $e->entity($this->_entity); } } if ($e instanceof \Zbase\Ui\Form\ElementInterface) { if (!empty($tabName)) { $e->setTab($tabName); } if ($this->isValueToSession()) { $e->setValue(zbase_session_get($e->id())); } } if ($e instanceof \Zbase\Widgets\EntityInterface) { $e->entity($this->_entity); } if ($e instanceof \Zbase\Widgets\Type\FormInterface) { $widgetElements = $e->elements(); if (!empty($widgetElements)) { foreach ($widgetElements as $widgetElement) { if (!empty($element['widget']) && !empty($element['prefix'])) { $widgetElement->setIdPrefix($element['prefix']); if ($this->isValueToSession()) { $widgetElement->setValue(zbase_session_get($widgetElement->id())); } } if (!empty($tabName)) { if ($widgetElement instanceof \Zbase\Ui\Form\ElementInterface) { $widgetElement->setTab($tabName); } if ($widgetElement instanceof \Zbase\Interfaces\ValidationInterface) { if ($widgetElement->hasValidations()) { //$currentTab = zbase_request_input('tab', false); //if(zbase_request_method() == 'post' && !empty($currentTab)) //{ $widgetValidationRules = $widgetElement->getValidationRules($this->getAction()); if (!is_array($widgetValidationRules)) { $widgetValidationRules = [$widgetElement->getId() => $widgetValidationRules]; } $this->_validationRules = array_replace_recursive($this->_validationRules, $widgetValidationRules); $this->_validationMessages = array_replace_recursive($this->_validationMessages, $widgetElement->getValidationMessages($this->getAction())); //} } } } } } else { if ($e instanceof \Zbase\Ui\Form\ElementInterface) { if ($e instanceof \Zbase\Interfaces\ValidationInterface) { if ($e->hasValidations()) { $widgetValidationRules = $e->getValidationRules($this->getAction()); if (!is_array($widgetValidationRules)) { $widgetValidationRules = [$e->getId() => $widgetValidationRules]; } $this->_validationRules = array_replace_recursive($this->_validationRules, $widgetValidationRules); $this->_validationMessages = array_replace_recursive($this->_validationMessages, $e->getValidationMessages($this->getAction())); } } } } } $currentTab = zbase_request_input('tab', false); if ($e instanceof \Zbase\Interfaces\ValidationInterface) { if ($e->hasValidations()) { $formTag = $this->_v('form_tab', true); if (zbase_request_method() == 'post' && empty($formTag) && !empty($currentTab)) { if ($tabName == $currentTab) { if (!isset($this->_validationRules['_tab' . $tabName])) { $this->_validationRules['_tab' . $tabName] = []; } $this->_validationRules['_tab' . $tabName][$e->name()] = $e->getValidationRules($this->getAction()); $this->_validationMessages = array_replace_recursive($this->_validationMessages, $e->getValidationMessages($this->getAction())); } } // if(zbase_request_method() == 'post' && empty($formTag) && !empty($currentTab)) // { // if($tabName == $currentTab) // { // $this->_validationRules[$e->name()] = $e->getValidationRules($this->getAction()); // $this->_validationMessages = array_replace_recursive($this->_validationMessages, $e->getValidationMessages($this->getAction())); // } // } // else // { // $this->_validationRules[$e->name()] = $e->getValidationRules($this->getAction()); // $this->_validationMessages = array_replace_recursive($this->_validationMessages, $e->getValidationMessages($this->getAction())); // } } // if(zbase_request_method() == 'post') // { // var_dump(zbase_request_inputs()); // var_dump($currentTab . '-' . $tabName); // } } return $e; }
/** * Create an Element * @param array $configuration * @return \Zbase\Ui\Form\ElementInterface */ function zbase_ui_form_element($configuration) { return \Zbase\Ui\Form\Element::factory($configuration); }