public function getForm(array $usersData, array $positionsData, array $currencyData, array $defaultStatus) { if (!$this->form) { $hidId = new Element\Hidden(); $hidId->setName('staffId'); $selectUsers = new Element\Select(); $selectUsers->setName('userId')->setLabel('User')->setAttribute('class', 'form-control')->setEmptyOption("--Choose User --")->setValueOptions($usersData); $staffCode = new Element\Text(); $staffCode->setLabel('Code')->setName("staffCode")->setAttribute('class', 'form-control'); $staffName = new Element\Text(); $staffName->setLabel('Name')->setName("staffName")->setAttribute('class', 'form-control'); $selectPosition = new Element\Select(); $selectPosition->setName('positionId')->setLabel('Position')->setAttribute('class', 'form-control')->setEmptyOption("-- Choose Position --")->setValueOptions($positionsData); $selectDepartment = new Element\Hidden('departmentId'); $salary = new Element\Number(); $salary->setLabel('Salary')->setName("salary")->setAttributes(array('min' => '0', 'max' => '999999999999', 'step' => '1')); $leave = new Element\Number(); $leave->setLabel('Leave')->setName("annual_leave")->setAttributes(array('min' => '0.5', 'max' => '100', 'step' => '0.5')); $PermanentDate = new Element\Date('permanentDate'); $PermanentDate->setLabel('P-Date')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD'))); $birthDay = new Element\Date('birthday'); $birthDay->setLabel('Birthday')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD'))); $selectCurrency = new Element\Select(); $selectCurrency->setName('currencyId')->setAttribute('class', 'form-control')->setValueOptions($currencyData); $status = new Element\Select(); $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($defaultStatus); $bankCode = new Element\Text('bankCode'); $bankCode->setLabel('Bank Account')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Aya Bank Account No')); $form = new Form(); $form->setAttribute('class', 'form-horizontal'); $form->add($hidId); $form->add($selectUsers); $form->add($staffCode); $form->add($staffName); $form->add($selectPosition); $form->add($selectDepartment); $form->add($salary); $form->add($leave); $form->add($PermanentDate); $form->add($status); $form->add($birthDay); $form->add($selectCurrency); $form->add($bankCode); $this->form = $form; } return $this->form; }
public function addElements() { $id = new Element\Text('id'); $id->setLabel('ID')->setAttribute('class', 'form-control')->setAttribute('type', 'hidden'); $this->add($id); $rating = new Element\Number('rating'); $rating->setLabel('Rating .Max = 5 (Good) , Min=0 (no rating)')->setAttribute('class', 'form-control')->setAttribute('type', 'hidden'); $this->add($rating); $name = new Element\Text('name'); $name->setLabel('Lazada name')->setAttribute('class', 'form-control')->setAttribute('required', 'true')->setAttribute('onchange', 'get_alias();')->setAttribute('id', 'name'); $this->add($name); $alias = new Element\Text('alias'); $alias->setLabel('Lazada alias')->setAttribute('required', 'true')->setAttribute('class', 'form-control')->setAttribute('id', 'alias'); $this->add($alias); $availability = new Element\Number('availability'); $availability->setLabel('Availability')->setAttribute('class', 'form-control')->setAttribute('required', 'true')->setAttribute('id', 'availability'); $this->add($availability); $descripts = new Element\Textarea('description'); $descripts->setLabel('Description short')->setAttribute('class', 'form-control')->setAttribute('id', 'descripts'); $this->add($descripts); $description = new Element\Textarea('detail_product'); $description->setLabel('Detail Lazada')->setAttribute('class', 'form-control')->setAttribute('id', 'detail_product'); $this->add($description); $hot = new Element\Radio('hot'); $hot->setLabel('Choice hot')->setValueOptions(array('0' => 'No Hot', '1' => 'Hot'))->setAttribute('id', 'hot'); $this->add($hot); $promotions = new Element\Number('promotions'); $promotions->setLabel('Promotions')->setAttribute('class', 'form-control')->setAttribute('id', 'promotions'); $this->add($promotions); $new = new Element\Radio('new'); $new->setLabel('Choice new')->setValueOptions(array('0' => 'No New', '1' => 'New'))->setAttribute('id', 'new'); $this->add($new); $status = new Element\Radio('status'); $status->setLabel('status')->setAttribute('required', 'true')->setValueOptions(array('0' => 'Pause', '1' => 'Active'))->setAttribute('id', 'status'); $this->add($status); $about_price = new Element\Number('about_price'); $about_price->setLabel('About Price')->setAttribute('class', 'form-control')->setAttribute('id', 'about_price'); $this->add($about_price); $weekly_featured = new Element\Radio('weekly_featured'); $weekly_featured->setLabel('Weekly featured')->setValueOptions(array('0' => 'No', '1' => 'Yes'))->setAttribute('id', 'weekly_featured'); $this->add($weekly_featured); $featured_products = new Element\Radio('featured_products'); $featured_products->setLabel('Featured Lazadas')->setValueOptions(array('0' => 'No', '1' => 'Yes'))->setAttribute('id', 'featured_products'); $this->add($featured_products); $new_products = new Element\Radio('new_products'); $new_products->setLabel('New Lazadas')->setValueOptions(array('0' => 'No', '1' => 'Yes'))->setAttribute('id', 'new_products'); $this->add($new_products); $sale_products = new Element\Radio('sale_products'); $sale_products->setLabel('Sale Lazadas')->setValueOptions(array('0' => 'No', '1' => 'Yes'))->setAttribute('id', 'sale_products'); $this->add($sale_products); $img = new Element\File('img'); $img->setLabel('file img (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img'); $this->add($img); $img1 = new Element\File('img1'); $img1->setLabel('file img1 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img1'); $this->add($img1); $img2 = new Element\File('img2'); $img2->setLabel('file img2 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img2'); $this->add($img2); $img3 = new Element\File('img3'); $img3->setLabel('file img3 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img3'); $this->add($img3); $img4 = new Element\File('img4'); $img4->setLabel('file img4 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img4'); $this->add($img4); $img5 = new Element\File('img5'); $img5->setLabel('file img5 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img5'); $this->add($img5); $img6 = new Element\File('img6'); $img6->setLabel('file img6 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img6'); $this->add($img6); $img7 = new Element\File('img7'); $img7->setLabel('file img7 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img7'); $this->add($img7); $img8 = new Element\File('img8'); $img8->setLabel('file img8 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img8'); $this->add($img8); $img9 = new Element\File('img9'); $img9->setLabel('file img9 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img9'); $this->add($img9); $img10 = new Element\File('img10'); $img10->setLabel('file img10 (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img10'); $this->add($img10); }
public function buildForm() { $this->setAttributes(array('id' => 'post-form', 'method' => 'post')); $category = new Element\Select('category'); $category->setLabel('Categoria'); $category->setValueOptions(array_combine($this->categories, $this->categories)); $category->setAttribute('class', 'form-control'); $title = new Element\Text('title'); $title->setLabel('Título'); $title->setAttributes(array('maxlength' => 128, 'class' => 'form-control')); $description = new Element\Textarea('description'); $description->setAttribute('class', 'form-control'); $description->setLabel('Descrição'); $photoFilename = new Element\Url('photo_filename'); $photoFilename->setAttribute('class', 'form-control'); $photoFilename->setLabel('Foto'); $contactName = new Element\Text('contact_name'); $contactName->setAttribute('class', 'form-control'); $contactName->setLabel('Nome completo'); $contactEmail = new Element\Email('contact_email'); $contactEmail->setAttribute('class', 'form-control'); $contactEmail->setLabel('E-mail'); $contactPhone = new Element\Text('contact_phone'); $contactPhone->setAttribute('class', 'form-control'); $contactPhone->setLabel('Contato'); $cityCode = new Element\Select('cityCode'); $cityCode->setAttribute('class', 'form-control'); $cityCode->setValueOptions($this->cities); $cityCode->setLabel('Cidade'); $deleteCode = new Element\Number('delete_code'); $deleteCode->setAttribute('class', 'form-control'); $deleteCode->setLabel('Código de deleção'); $captcha = new Element\Captcha('captcha'); $captchaAdapter = new ImageCaptcha(array('font' => './public/fonts/arial.ttf', 'imgDir' => './public/img/captcha', 'imgUrl' => '/img/captcha')); $captchaAdapter->setWordlen(4); $captcha->setCaptcha($captchaAdapter)->setLabel('Você é um ser humano ou um robô?')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Você é um ser humano ou um robô?'); /*$captcha = new Element\Captcha('captcha'); $captcha->setCaptcha(new \Zend\Captcha\Dumb()); $captcha->setAttribute('class', 'form-control'); $captcha->setOptions(array('label' => 'Você é um ser humano ou um robô?')); */ $price = new Element\Number('price'); $price->setAttributes(array('class' => 'form-control', 'maxlength' => 12, 'min' => 0, 'max' => '999999999999')); $price->setLabel('Preço'); $dateExpires = new Element\Radio('date_expires'); $dateExpires->setLabel('Expira em (dias)'); $dateExpires->setValueOptions(array_combine($this->dateExpires, $this->dateExpires)); $csrf = new Element\Csrf('security'); $submit = new Element\Submit('submit'); $submit->setAttributes(array('class' => 'btn btn-default', 'value' => 'Enviar formulário')); $this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode)->add($captcha)->add($csrf)->add($submit); /* $factory = new \Zend\Form\Factory(); $factory->createForm(array( 'hydrator' => 'Zend\Stdlib\Hydrator\ArraySerializable', 'elements' => array( array( 'name' => 'category', 'type' => 'text', 'options' => array( 'label' => 'Category' ) ), array( 'name' => 'title', 'type' => 'text', 'options' => array( 'label' => 'Title' ) ), ) )); */ }
/** * Prepara os campos do formulário * @param string $fieldName * @param array $fieldParams * @param array $options * @return object * @throws Exception */ private function prepareFields($fieldName, array $fieldParams, array $options = array()) { $element = null; $extraLabel = " "; $this->aOptions = array(); $this->aAttributes = array(); /* Define o tooltip do campo */ $tooltip = (isset($fieldParams['tooltip']) and $fieldParams['tooltip'] == 'true') ? "<a class=\"tooltip-marc\" href=\"#\" data-toggle=\"tooltip\" title=\"{$this->getTranslator($fieldName . '_tooltip')}\">[?]</a>" : null; $this->aOptions['tooltip'] = $tooltip; /* Define como será mostrado o nome do campo (se é obrigatório ou não) */ if (strtolower($fieldParams['type']) != 'hidden') { if (isset($fieldParams['validation']) and stristr(strtolower($fieldParams['validation']), "required")) { $extraLabel = " * "; } } switch (strtolower($fieldParams['type'])) { /* Caso hidden */ case 'primary': case 'hidden': $element = new ZendFormElement\Hidden($fieldName); break; /* Caso Csrf */ /* Caso Csrf */ case 'csrf': case 'sec': $element = new ZendFormElement\Csrf($fieldName); $element->setCsrfValidatorOptions(array('timeout' => '600')); break; /* Caso text */ /* Caso text */ case 'text': $element = new ZendFormElement\Text($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso textarea */ /* Caso textarea */ case 'textarea': $element = new ZendFormElement\Textarea($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); /* Define os padrões de colunas e linhas do campo */ $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5; $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10; $this->aAttributes['class'] = 'form-input'; $this->aAttributes['data-editor'] = 'false'; break; /* Caso editor */ /* Caso editor */ case 'editor': $element = new ZendFormElement\Textarea($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); /* Define os padrões de colunas e linhas do campo */ $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5; $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10; /* Verifica se utilizará o editor */ $this->aAttributes['class'] = 'editorw'; $this->aAttributes['data-editor'] = 'true'; /* Verifica a pasta de upload */ if (isset($this->formDefaultConfig['destination']) and !empty($this->formDefaultConfig['destination'])) { /* Caso não exista a pasta cria o mesmo */ if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['destination'])) { mkdir(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777, true); chmod(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777); } $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = false; $_SESSION['KCFINDER']['uploadURL'] = URL_UPLOAD . $this->formDefaultConfig['destination']; $_SESSION['KCFINDER']['uploadDir'] = UPLOAD_PATH . $this->formDefaultConfig['destination']; } else { throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500); } break; /* Caso password */ /* Caso password */ case 'password': $element = new ZendFormElement\Password($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['renderPassword'] = true; $this->aAttributes['class'] = 'form-input'; break; /* Caso radio */ /* Caso radio */ case 'radio': $element = new ZendFormElement\Radio($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'radio'; break; /* Caso checkbox */ /* Caso checkbox */ case 'checkbox': $element = new ZendFormElement\Checkbox($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $element->setUncheckedValue(null); $this->aAttributes['class'] = 'checkbox'; break; /* Caso multicheckbox */ /* Caso multicheckbox */ case 'multicheckbox': $element = new ZendFormElement\MultiCheckbox($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $element->setUncheckedValue(null); break; /* Caso select */ /* Caso select */ case 'select': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->selectOptions = array(); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso selectgroup */ /* Caso selectgroup */ case 'selectgroup': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->selectOptions = array(); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso multiselect */ /* Caso multiselect */ case 'multiselect': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input-select ms'; $this->aAttributes['multiple'] = 'multiple'; break; /* Caso fileimage */ /* Caso fileimage */ case 'fileimage': $element = new ZendFormElement\File($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); //$this->aAttributes['multiple'] = true; $this->aAttributes['class'] = 'hiddenImageFile'; /* Verifica a pasta de upload */ if (isset($this->formDefaultConfig['pathfiles']) and !empty($this->formDefaultConfig['pathfiles'])) { /* Caso não exista a pasta cria o mesmo */ if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'])) { mkdir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777, true); chmod(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777); } $this->aAttributes['data-path'] = LINK_DEFAULT . 'uploads/' . $this->formDefaultConfig['pathfiles']; } else { throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500); } break; /* Caso file */ /* Caso file */ case 'file': $element = new ZendFormElement\File($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); break; case 'money': $element = new ZendFormElement\Text($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* HTML5 Elements */ /* Caso url */ /* HTML5 Elements */ /* Caso url */ case 'url': $element = new ZendFormElement\Url($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso date */ /* Caso date */ case 'date': $element = new ZendFormElement\Date($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 10 . '-01-01'; $this->aAttributes['max'] = date("Y") + 10 . '-12-31'; $this->aAttributes['class'] = 'form-input'; break; case 'dateage': $element = new ZendFormElement\Date($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 100 . '-01-01'; $this->aAttributes['max'] = date("Y") + 100 . '-12-31'; $this->aAttributes['class'] = 'form-input'; break; /* Caso time */ /* Caso time */ case 'time': $element = new ZendFormElement\DateTime($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; $this->aAttributes['min'] = '00:00:00'; $this->aAttributes['max'] = '23:59:59'; $this->aOptions['format'] = 'H:i:s'; break; /* Caso date */ /* Caso date */ case 'datetime': $element = new ZendFormElement\DateTime($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 10 . '-01-01 00:00:00'; $this->aAttributes['max'] = date("Y") + 10 . '-12-31 23:59:59'; $this->aAttributes['class'] = 'form-input'; break; /* Caso email */ /* Caso email */ case 'email': $element = new ZendFormElement\Email($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso number */ /* Caso number */ case 'number': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['step'] = '1'; $this->aAttributes['class'] = 'form-input'; break; case 'integer': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = '0'; $this->aAttributes['max'] = '99999999999999999999'; $this->aAttributes['step'] = '1'; $this->aAttributes['class'] = 'form-input'; break; case 'float': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['step'] = '0.001'; $this->aAttributes['class'] = 'form-input'; break; /* Plataforma */ /* Caso select */ /* Plataforma */ /* Caso select */ case 'status': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso boolean */ /* Caso boolean */ case 'boolean': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; } /* Verifica se foi setado classe de estilo e implementa */ if (isset($fieldParams['class']) and !empty($fieldParams['class'])) { if (isset($this->aAttributes['class']) and $this->aAttributes['class'] != "") { $this->aAttributes['class'] = $this->aAttributes['class'] . " " . $fieldParams['class']; } else { $this->aAttributes['class'] = $fieldParams['class']; } } /* Define a descrição abaixo do campo */ if (isset($fieldParams['description']) and $fieldParams['description'] == 'true') { $this->aOptions['help-block'] = $this->getTranslator($fieldName . '_description'); } /* Verifica se foi setado grupo do campo e implementa */ if (isset($fieldParams['group']) and !empty($fieldParams['group'])) { $this->aOptions['group'] = $fieldParams['group']; } /* Verifica se foi setado placeholder no campo e implementa */ if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->aAttributes['placeholder'] = $this->getTranslator($fieldName . '_placeholder'); } /* Verifica se foi setado somente leitura e implementa */ if (isset($fieldParams['readonly']) and strtolower($fieldParams['readonly']) == 'true') { $this->aAttributes['readonly'] = 'readonly'; } /* Verifica se foi setado desabilitado e implementa */ if (isset($fieldParams['disabled']) and strtolower($fieldParams['disabled']) == 'true') { $this->aAttributes['disabled'] = true; } /* Verifica se utilizará mascara no campo */ if (isset($fieldParams['mask']) and !empty($fieldParams['mask'])) { $this->aAttributes['data-inputmask'] = $fieldParams['mask']; } /* Verifica se foi setado inputgroup tipo append e implementa */ if (isset($fieldParams['groupappend']) and !empty($fieldParams['groupappend'])) { $this->aOptions['add-on-append'] = $fieldParams['groupappend']; } /* Verifica se foi setado inputgroup tipo prepend e implementa */ if (isset($fieldParams['groupprepend']) and !empty($fieldParams['groupprepend'])) { $this->aOptions['add-on-prepend'] = $fieldParams['groupprepend']; } /* Verifica se foi setado como array e implementa */ if (isset($fieldParams['array']) and strtolower($fieldParams['array']) == 'true') { $this->aOptions['disable_inarray_validator'] = false; } if (strtolower($fieldParams['type']) !== 'checkbox' and strtolower($fieldParams['type']) !== 'button') { if (strtolower($fieldParams['type']) !== 'textarea' and strtolower($fieldParams['type']) !== 'editor') { //$this->aOptions['column-size'] = 'col4'; } else { //$this->aOptions['column-size'] = 'col6'; } $this->aOptions['labelattributes'] = array('class' => 'form-label'); } else { //$this->aOptions['column-size'] = 'col6 col-sm-offset-2'; unset($this->aOptions['labelattributes']); } return array('element' => $element, 'params' => $fieldParams); }