/** * Generates a widget to show a html grid Form * * @param \Engine\Crud\Form\Field $Form * @return string */ public static function _(Field $field) { $desc = $field->getDesc(); $code = ''; if ($desc) { $code = '<span>' . $field->getDesc() . '</span>'; } return $code; }
/** * Generates a widget to show a html grid Form * * @param \Engine\Crud\Form\Field $Form * @return string */ public static function _(Field $field) { $label = $field->getLabel(); $code = ''; if ($label) { $code = '<label class="control-label" for="' . $field->getKey() . '">' . $field->getLabel() . '</label>'; } return $code; }
/** * Render extjs mail form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'textfield'"; } if ($field->isNotEdit()) { $fieldCode[] = "readOnly: true"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $fieldCode[] = "vtype: 'email'"; return forward_static_call(['self', '_implode'], $fieldCode); }
/** * @param string $label * @param string $name * @param bool $checked * @param int|string $checkedValue * @param int|string $uncheckedValue * @param string $desc * @param bool $required * @param int $width * @param int $length */ public function __construct($label = null, $name = null, $checked = false, $checkedValue = 1, $uncheckedValue = 0, $desc = null, $required = false, $width = 280, $length = 255) { parent::__construct($label, $name, $desc, $required, $width, $checked); $this->_checked = $checked; $this->_checkedValue = $checkedValue; $this->_uncheckedValue; }
/** * Generates a widget to show a html grid Form * * @param \Engine\Crud\Form\Field $Form * @return string */ public static function _(Field $field) { $code = ''; $element = $field->getElement(); //Get any generated messages for the current element $messages = $element->getMessages(); if (count($messages)) { //Print each element $code .= '<div class="messages">'; foreach ($messages as $message) { $code .= $message; } $code .= '</div>'; } return $code; }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { if (null === $this->_id) { $this->_required = true; } parent::_init(); $this->_validators[] = ['validator' => 'StringLength', 'options' => ['min' => $this->_length]]; }
/** * Render filter form field * * @param \Engine\Crud\Form\Field $field * @return string */ public function renderField(Field $field) { $helpers = $field->getHelpers(); foreach ($helpers as $i => $helper) { $helpers[$i] = Helper::factory($helper, $field); } $sections = []; foreach ($helpers as $helper) { $sections[] = call_user_func_array([$helper['helper'], '_'], [$helper['element']]); } $separator = $this->getSeparator(); $elementContent = implode($separator, $sections); foreach (array_reverse($helpers) as $helper) { $elementContent .= $sections[] = call_user_func([$helper['helper'], 'endTag']); } return $elementContent; }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { if (null === $this->_id) { $this->_required = true; } parent::_init(); $passwrodField = $this->_form->getFieldByKey($this->_confirmField); $passwrodField->addValidator(['validator' => 'Confirmation', 'options' => ['with' => $this->_key, 'message' => $this->_errorMessage]]); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); /*$this->_validators[] = [ 'validator' => 'Regex', 'options' => [ 'pattern' => '/^([a-zA-Z0-9_\.\-+])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/i', 'messages' => "Invalid mail address" ] ];*/ $this->_validators[] = 'email'; }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); if ($this->_lengthMax || $this->_lengthMin) { $options = []; if ($this->_lengthMax) { $options['max'] = $this->_lengthMax; } if ($this->_lengthMin) { $options['min'] = $this->_lengthMin; } $this->_validators[] = ['validator' => 'StringLength', 'options' => $options]; } }
/** * Set form field value * * @param array|int|string $value * @return \Engine\Crud\Tools\FormElements */ public function setValue($value) { //$value = str_replace ( "-", "/", $value ); //$value = date ( 'm-d-Y', strtotime ( $value ) ); $date = new \DateTime($value); $value = $date->format($this->_format); return parent::setValue($value); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); $this->_validators[] = ['validator' => 'Numericality', 'options' => []]; $this->_validators[] = ['validator' => 'Between', 'options' => ['minimum' => $this->_min, 'maximum' => $this->_max, 'messages' => "The value must be between '" . $this->_min . "' and '" . $this->_max . "'"]]; }
/** * Return field value * * @return string|array */ public function getValue() { $key = $this->getKey(); if (array_key_exists($key, $_FILES)) { return $_FILES[$key]['name']; } return parent::getValue(); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); if ($this->_name) { throw new \Engine\Exception("Outdated ManyToMany settings for " . get_class($this->_form) . " - " . get_class($this->_model)); } if (!$this->_noTableReference) { $workingModel = $this->_getWorkModel(); $relationsRefModel = $workingModel->getRelationPath($this->_model); if (!$relationsRefModel) { throw new \Engine\Exception("Did not find relations between '" . get_class($this->_workingModel) . "' and '" . get_class($this->_model) . "'"); } $mainModel = $this->_form->getContainer()->getModel(); $relationsMainModel = $workingModel->getRelationPath($mainModel); if (!$relationsMainModel) { throw new \Engine\Exception("Did not find relations between '" . get_class($this->_workingModel) . "' and '" . get_class($mainModel) . "'"); } $this->_name = array_shift($relationsRefModel)->getFields(); $this->_keyParent = array_shift($relationsMainModel)->getFields(); } $this->setAttrib("autoLoad", true); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); $this->_validators[] = array('validator' => 'Regex', 'options' => ['pattern' => '/^[ +()_-\\d]{6,}(\\s(x|ext\\.?)\\s?\\d{3,4})?$/i']); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); $model = $this->_form->getContainer()->getModel(); $this->_name = $model->getNameExpr(); }
/** * Initialize field (used by extending classes) * * @return void */ protected function _init() { parent::_init(); $this->_validators[] = array('validator' => 'Regex', 'options' => ['pattern' => '/^(http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\'/\\\\+&%\\$#\\=~])*$/']); }
/** * Return field value * * @return string */ public function getValue() { $value = parent::getValue(); if ($this->_asynchron === false) { $options = $this->getOptions(); $options = array_combine(array_values($options), array_keys($options)); $value = $options[$value]; } return $value; }