public function __construct($name = null, $options = array()) { //Formulario //Contruimos el formulario en base al padre parent::__construct('login', $options); //seteamos el actiond el formulario $this->setAttributes(array('action' => '/application/index/login')); //Elementos //Creamos un elemento de tipo texto y seteamos su atributo name $e = new Element\Text('name'); //Seteamos los atributos del elemento $e->setAttributes(array('id' => 'txt_name', 'class' => 'txt_name_clase')); //seteamos las opciones del elemento $e->setOptions(array('label' => 'Usuario: ')); //añadimos al formulario $this->add($e); //Definimos los parametros del elemento a generar $e = array('type' => 'password', 'name' => 'password', 'attributes' => array('id' => `txt_password`, 'class' => 'txt_password_clase'), 'options' => array('label' => 'Clave: ')); //agregamo el elemento $this->add($e); //Agregando un boton $e = new Element\Submit('enviar'); $e->setAttributes(array('id' => `btn_login`, 'value' => 'Enviar', 'class' => 'btn_login')); $this->add($e); }
/** * @param null|string $name */ public function __construct($serviceLocator, $options = null) { parent::__construct('passwordForgot'); $this->setServiceLocator($serviceLocator); $this->setAttribute('method', 'post'); $filter = $this->getInputFilter(); $groupBasic = new DisplayGroup('groupBasic'); $this->add($groupBasic); $email = new Text('email'); $email->setLabel('Email:'); $email->setAttributes(['maxlength' => 255, 'autocomplete' => 'off']); $email->setOptions(['descriptions' => ['Nhập email khi bạn đăng ký tài khoản']]); $this->add($email); $groupBasic->addElement($email); $filter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 50, 'min' => 4, 'messages' => array(StringLength::TOO_LONG => 'Tên đăng nhập giới hạn 4-50 kí tự', StringLength::TOO_SHORT => 'Tên đăng nhập giới hạn 4-50 kí tự'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ')))))); $config = $this->getServiceLocator()->get('Config'); $this->captcha = new ReCaptcha(array('pubkey' => $config['captcha']['reCAPTCHA']['publicKey'], 'privkey' => $config['captcha']['reCAPTCHA']['privateKey'], 'ssl' => !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? false : true)); $this->captcha->setPrivkey($config['captcha']['reCAPTCHA']['privateKey']); $this->captcha->setPubkey($config['captcha']['reCAPTCHA']['publicKey']); $captcha = new Captcha('captcha'); $captcha->setLabel('Mã bảo mật:'); $captcha->setCaptcha($this->captcha); $this->add($captcha); $groupBasic->addElement($captcha); $filter->add(array('name' => 'captcha', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), $this->captcha))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Khôi phục mật khẩu', 'id' => 'btnSubmit', 'class' => 'htmlBtn first btn btn-primary'), 'options' => array('clearBefore' => true, 'decorator' => array('type' => 'li', 'attributes' => array('class' => 'btns'))))); }
public function setOptions($options) { parent::setOptions($options); if (isset($options['engine_type'])) { $this->setType($options['engine_type']); } return $this; }
/** * Load textstring prevalue editor * * @return Element\Text */ public function load() { $config = $this->getConfig(); $length = new Element\Text('length'); $length->setAttributes(array('value' => isset($config['length']) ? $config['length'] : '', 'class' => 'form-control', 'id' => 'length')); $length->setOptions(array('label' => 'Length', 'label_attributes' => array('class' => 'required control-label col-lg-2'))); return $length; }
/** * {@inheritDoc} */ public function form(PhpRenderer $view, array $options = []) { $urlInput = new UrlElement('o:media[__index__][o:source]'); $urlInput->setOptions(['label' => $view->translate('Video URL'), 'info' => $view->translate('URL for the video to embed.')]); $urlInput->setAttributes(['id' => 'media-youtube-source-__index__', 'required' => true]); $urlInput->setAttributes(['id' => 'media-youtube-source-__index__', 'required' => true]); $startInput = new Text('o:media[__index__][start]'); $startInput->setOptions(['label' => $view->translate('Start'), 'info' => $view->translate('Begin playing the video at the given number of seconds from the start of the video.')]); $endInput = new Text('o:media[__index__][end]'); $endInput->setOptions(['label' => $view->translate('End'), 'info' => $view->translate('End playing the video at the given number of seconds from the start of the video.')]); return $view->formRow($urlInput) . $view->formRow($startInput) . $view->formRow($endInput); }
/** * {@inheritDoc} */ public function form(PhpRenderer $view, array $options = []) { $titleInput = new TextInput('o:media[__index__][dcterms:title][0][@value]'); $titlePropertyInput = new Hidden('o:media[__index__][dcterms:title][0][property_id]'); //make sure we have correct dcterms:title id $api = $view->api(); $dctermsTitle = $api->search('properties', ['term' => 'dcterms:title'])->getContent()[0]; $titlePropertyInput->setValue($dctermsTitle->id()); $titleInput->setOptions(['label' => $view->translate('Title'), 'info' => $view->translate('A title for the HTML content')]); $html = $view->formRow($titleInput); $html .= $view->formRow($titlePropertyInput); $html .= $this->getForm($view, 'media-html-__index__'); return $html; }
/** * Load Textarea prevalue editor * - cols: Number of caracters display per line * - rows: Define the number of line visible in text zone * - wrap: Possible values are : hard / off / soft * define if line returns are automatic (hard / soft) * or if the horizontal display if exceeded (off) * * @return mixed */ public function load() { $config = $this->getConfig(); $cols = new Element\Text('cols'); $cols->setAttributes(array('value' => isset($config['cols']) ? $config['cols'] : '', 'class' => 'form-control')); $cols->setOptions(array('label' => 'Cols', 'label_attributes' => array('class' => 'required control-label col-lg-2'))); $rows = new Element\Text('rows'); $rows->setAttributes(array('value' => isset($config['rows']) ? $config['rows'] : '', 'class' => 'form-control')); $rows->setOptions(array('label' => 'Rows', 'label_attributes' => array('class' => 'required control-label col-lg-2'))); $wrap = new Element\Select('wrap'); $wrap->setAttributes(array('class' => 'form-control', 'options' => array('hard' => 'hard', 'off' => 'off', 'soft' => 'soft'), 'value' => isset($config['wrap']) ? $config['wrap'] : '')); $wrap->setOptions(array('label' => 'Wrap', 'label_attributes' => array('class' => 'required control-label col-lg-2'))); return array($cols, $rows, $wrap); }
public function __construct($serviceLocator, $options = null) { parent::__construct('AccountIndex'); $this->setServiceLocator($serviceLocator); $this->setAttribute('method', 'post'); $filter = $this->getInputFilter(); $group = new DisplayGroup('Subject'); $group->setLabel('Thêm mentor'); $this->add($group); // name $userName = new Text('userName'); $userName->setLabel('Người dùng: '); $userName->setAttributes(['maxlength' => 255]); if ($options == 'edit') { $userName->setAttribute('disabled', 'disabled'); } $this->add($userName); $group->addElement($userName); $filter->add(array('name' => 'userName', 'required' => $options == 'edit' ? false : true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập người dùng')))))); $userId = new Hidden('userId'); $this->add($userId); $group->addElement($userId); $filter->add(array('name' => 'userId', 'required' => $options == 'edit' ? false : true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập người dùng')))))); // code $description = new Textarea('description'); $description->setLabel('Mô tả mentor:'); $description->setAttributes(['class' => 'form-control basicEditor ', 'style' => 'min-height: 300px;']); $this->add($description); $group->addElement($description); $filter->add(array('name' => 'description', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập mô tả môn học')))))); $subject = new Text('subject'); $subject->setLabel('Tên môn:'); $subject->setAttributes(['maxlength' => 255, 'style' => 'width:100% !important', 'placeholder' => 'Tên môn học']); $subject->setOptions(array('tagsinput' => true, 'description' => 'Tên môn học')); $this->add($subject); $group->addElement($subject); $filter->add(array('name' => 'subject', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên môn')))))); $subjectId = new Hidden('subjectId'); $subjectId->setLabel('Tên môn:'); $this->add($subjectId); $group->addElement($subjectId); $filter->add(array('name' => 'subjectId', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên môn')))))); $this->add(array('name' => 'afterSubmit', 'type' => 'radio', 'attributes' => array('value' => '/admin/expert/add'), 'options' => array('layout' => 'fluid', 'clearBefore' => true, 'label' => 'Sau khi lưu dữ liệu:', 'value_options' => array('/admin/expert/add' => 'Tiếp tục nhập', '/admin/expert/index' => 'Hiện danh sách vừa nhập')))); $this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary'))); }
public function __construct($serviceLocator, $options = null) { parent::__construct('AccountIndex'); $this->setServiceLocator($serviceLocator); $this->setAttribute('method', 'post'); $filter = $this->getInputFilter(); $group = new DisplayGroup('Subject'); $group->setLabel('Thêm mentor'); $this->add($group); $subject = new Text('subject'); $subject->setLabel('Tên môn:'); $subject->setAttributes(['maxlength' => 255, 'style' => 'width:100% !important', 'placeholder' => 'Tên môn học']); $subject->setOptions(array('tagsinput' => true, 'description' => 'Tên môn học')); $this->add($subject); $group->addElement($subject); $filter->add(array('name' => 'subject', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên môn')))))); $subjectId = new Hidden('subjectId'); $subjectId->setLabel('Tên môn:'); $this->add($subjectId); $group->addElement($subjectId); $filter->add(array('name' => 'subjectId', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên môn')))))); $this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary'))); }
/** * @param null|string $name */ public function __construct($serviceLocator, $options = null) { parent::__construct('fUserAdd'); $this->setServiceLocator($serviceLocator); $this->setAttribute('method', 'post'); $filter = $this->getInputFilter(); $groupBasic = new DisplayGroup('groupBasic'); $groupBasic->setLabel('Thông tin cơ bản'); $this->add($groupBasic); $username = new Text('username'); $username->setLabel('Tên đăng nhập:'); $username->setAttributes(['maxlength' => 50, 'autocomplete' => 'off']); $this->add($username); $groupBasic->addElement($username); $filter->add(array('name' => 'username', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StringToLower')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên đăng nhập'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 50, 'min' => 4, 'messages' => array(StringLength::TOO_LONG => 'Tên đăng nhập giới hạn 4-50 kí tự', StringLength::TOO_SHORT => 'Tên đăng nhập giới hạn 4-50 kí tự'))), array('name' => 'Regex', 'break_chain_on_failure' => true, 'options' => array('pattern' => "/^[a-z0-9_-]{4,32}\$/", 'messages' => array('regexNotMatch' => 'Chỉ chấp nhận các kí tự là chữ, chữ số, dấu - và dấu _'))), array('name' => 'Db\\NoRecordExists', 'options' => array('table' => 'users', 'field' => 'username', 'adapter' => \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::getStaticAdapter(), 'messages' => array('recordFound' => "Tên đăng nhập này đã được sử dụng")))))); $fulName = new Text('fullName'); $fulName->setLabel('Họ tên:'); $fulName->setAttributes(['maxlength' => 255, 'autocomplete' => 'off']); $this->add($fulName); $groupBasic->addElement($fulName); $filter->add(array('name' => 'fullName', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập họ tên'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 255, 'min' => 4, 'messages' => array(StringLength::TOO_LONG => 'Tên đăng nhập giới hạn 4-250 kí tự', StringLength::TOO_SHORT => 'Tên đăng nhập giới hạn 4-250 kí tự')))))); $email = new Text('email'); $email->setLabel('Email:'); $email->setAttributes(['maxlength' => 255, 'autocomplete' => 'off']); $this->add($email); $groupBasic->addElement($email); $filter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 50, 'min' => 4, 'messages' => array(StringLength::TOO_LONG => 'Tên đăng nhập giới hạn 4-50 kí tự', StringLength::TOO_SHORT => 'Tên đăng nhập giới hạn 4-50 kí tự'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ'))), array('name' => 'Db\\NoRecordExists', 'options' => array('table' => 'users', 'field' => 'email', 'adapter' => \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::getStaticAdapter(), 'messages' => array('recordFound' => "Email này đã được sử dụng")))))); $user = new \User\Model\User(); $role = new Select('role'); $role->setLabel('Phân quyền:'); $role->setValueOptions(['' => '- Phân quyền -'] + $user->getRoleDisplays()); $this->add($role); $groupBasic->addElement($role); $filter->add(array('name' => 'role', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa chọn Phân quyền')))))); $password = new Password('password'); $password->setLabel('Mật khẩu:'); $password->setAttributes(['maxlength' => 32, 'autocomplete' => 'off']); $this->add($password); $groupBasic->addElement($password); $filter->add(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập Mật khẩu'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 32, 'min' => 6, 'messages' => array(StringLength::TOO_LONG => 'Mật khẩu giới hạn 6-32 kí tự', StringLength::TOO_SHORT => 'Mật khẩu giới hạn 6-32 kí tự')))))); $rePassword = new Password('rePassword'); $rePassword->setLabel('Nhập lại Mật khẩu:'); $rePassword->setAttributes(['maxlength' => 32, 'autocomplete' => 'off']); $this->add($rePassword); $groupBasic->addElement($rePassword); $filter->add(array('name' => 'rePassword', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập lại Mật khẩu'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 32, 'min' => 6, 'messages' => array(StringLength::TOO_LONG => 'Mật khẩu giới hạn 6-32 kí tự', StringLength::TOO_SHORT => 'Mật khẩu giới hạn 6-32 kí tự'))), array('name' => 'Identical', 'break_chain_on_failure' => true, 'options' => array('token' => 'password', 'messages' => array('notSame' => 'Xác nhận mật khẩu không chính xác')))))); $mobile = new Text('mobile'); $mobile->setLabel('Mobile:'); $mobile->setAttributes(['maxlength' => 15]); $mobile->setOptions(['leftIcon' => 'fa fa-mobile']); $this->add($mobile); $groupBasic->addElement($mobile); $filter->add(array('name' => 'mobile', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập Mobile'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('min' => 10, 'max' => 11, 'messages' => array(StringLength::INVALID => 'Mobile phải là dạng 10 hoặc 11 chữ số', StringLength::TOO_SHORT => 'Mobile phải là dạng 10 hoặc 11 chữ số', StringLength::TOO_LONG => 'Mobile phải là dạng 10 hoặc 11 chữ số')))))); // group additional $groupAdditional = new DisplayGroup('groupAdditional'); $groupAdditional->setLabel('Thông tin cá nhân'); $this->add($groupAdditional); $gender = new Select('gender'); $this->add($gender); $groupAdditional->addElement($gender); $gender->setLabel('Giới tính:'); $gender->setValueOptions(array('' => '- Giới tính -', \Home\Model\Consts::GENDER_MALE => 'Nam', \Home\Model\Consts::GENDER_FEMALE => 'Nữ')); $filter->add(array('name' => 'gender', 'required' => false, 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập Giới tính')))))); $birthdate = new Text('birthdate'); $birthdate->setLabel('Ngày sinh:'); $birthdate->setAttributes(['class' => 'datetimepicker', 'data-date-format' => "DD/MM/YYYY"]); $birthdate->setOptions(['leftIcon' => 'fa fa-calendar']); $this->add($birthdate); $groupAdditional->addElement($birthdate); $filter->add(array('name' => 'birthdate', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Date', 'break_chain_on_failure' => true, 'options' => array('format' => DateBase::getDisplayDateFormat(), 'messages' => array('dateInvalid' => 'Ngày sinh không hợp lệ', 'dateInvalidDate' => 'Ngày sinh không hợp lệ', 'dateFalseFormat' => 'Ngày sinh không hợp lệ')))))); $cityId = new Select('cityId'); $cityId->setLabel('Thành phố:'); $cityId->setValueOptions(array('' => '- Thành phố -')); $this->add($cityId); $groupAdditional->addElement($cityId); $filter->add(array('name' => 'cityId', 'required' => false, 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập thành phố'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 250, 'messages' => array(StringLength::INVALID => 'Địa chỉ chỉ giới hạn nhỏ hơn 250 kí tự')))))); $districtId = new Select('districtId'); $districtId->setLabel('Quận huyện:'); $districtId->setValueOptions(array('' => '- Quận huyện -')); $this->add($districtId); $groupAdditional->addElement($districtId); $filter->add(array('name' => 'districtId', 'required' => false, 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập thành phố')))))); $address = new Text('address'); $address->setLabel('Địa chỉ:'); $address->setAttributes(['maxlength' => 255]); $this->add($address); $groupAdditional->addElement($address); $filter->add(array('name' => 'address', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập địa chỉ')))))); $this->add(array('name' => 'afterSubmit', 'type' => 'radio', 'attributes' => array('value' => '/system/user/add'), 'options' => array('layout' => 'fluid', 'clearBefore' => true, 'label' => 'Sau khi lưu dữ liệu:', 'value_options' => array('/system/user/add' => 'Tiếp tục nhập người dùng', '/system/user/index' => 'Hiện danh sách người dùng')))); $this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSaveCrmContact', 'class' => 'btn btn-primary'))); }
/** * @param array|\Traversable $options * @return ObjectSelect */ public function setOptions($options) { if (!$this->initialized) { $this->setAttribute('data-zf2doctrineacclass', urlencode(str_replace('\\', '-', $options['class']))); $this->setAttribute('data-zf2doctrineacproperty', $options['property']); $this->setAttribute('data-zf2doctrineacselectwarningmessage', $options['select_warning_message']); $this->setAttribute('data-zf2doctrineacinit', 'zf2-doctrine-autocomplete'); if (isset($options['allow_persist_new']) && $options['allow_persist_new']) { $this->setAttribute('data-zf2doctrineacallowpersist', 'true'); } $this->initialized = true; } $this->getProxy()->setOptions($options); return parent::setOptions($options); }