public function __construct($name = 'mailchimp-sub-form', $options = array()) { parent::__construct($name, $options); $firstName = new Element\Text('firstName'); $firstName->setLabel('First Name'); $lastName = new Element\Text('lastName'); $lastName->setLabel('Last Name'); $email = new Element\Email('email'); $email->setLabel('Email Address'); $emailValidator = new Validator\EmailAddress(array('allow' => Validator\Hostname::ALLOW_DNS, 'domain' => true)); $email->setValidator($emailValidator); $privacyPolicy = new Element\Checkbox('privacyPolicy'); $privacyPolicy->setLabel('I accept the privacy policy and the terms of use'); $csrf = new Element\Csrf('mcSubCSRF'); $submit = new Element\Submit('submit'); $submit->setValue('Subscribe'); $this->add($firstName); $this->add($lastName); $this->add($email); $this->add($privacyPolicy); $this->add($csrf); $this->add($submit); $inputFilter = $this->getInputFilter(); $inputFilter->get($firstName->getName())->setAllowEmpty(false)->setRequired(true); $inputFilter->get($lastName->getName())->setAllowEmpty(false)->setRequired(true); }
/** * Init Module form * * @return void */ public function init() { $showEmail = new Element\Checkbox('show_email'); $showEmail->setLabel('Show email'); $showEmail->setAttribute('required', 'required')->setAttribute('id', 'show-email'); $username = new Element\Text('username'); $username->setLabel('Username'); $username->setAttribute('required', 'required')->setAttribute('id', 'username'); $email = new Element\Text('email'); $email->setLabel('Email'); $email->setAttribute('required', 'required')->setAttribute('id', 'email'); $message = new Element\Textarea('message'); $message->setLabel('Message'); $message->setAttribute('required', 'required')->setAttribute('id', 'message'); $captchaImage = new CaptchaImage(array('font' => GC_PUBLIC_PATH . '/backend/fonts/arial.ttf', 'width' => 250, 'height' => 50, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3)); $captchaImage->setImgDir(GC_PUBLIC_PATH . '/frontend/tmp'); $captchaImage->setImgUrl('/frontend/tmp'); $captcha = new Element\Captcha('captcha'); $captcha->setLabel('Please verify you are human')->setCaptcha($captchaImage)->setAttribute('required', 'required')->setAttribute('id', 'captcha'); $this->add($showEmail); $this->add($username); $this->add($email); $this->add($message); $this->add($captcha); $inputFilterFactory = new InputFilterFactory(); $inputFilter = $inputFilterFactory->createInputFilter(array('show_email' => array('name' => 'show_email', 'required' => false), 'username' => array('name' => 'username', 'required' => true), 'email' => array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'email_address'))), 'message' => array('name' => 'message', 'required' => true), 'captcha' => $captcha->getInputSpecification())); $this->setInputFilter($inputFilter); }
public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttribute('method', 'POST'); $this->setAttribute('class', 'form-horizontal'); //Input Titulo $titulo = new Text('titulo'); $titulo->setLabel('Titulo')->setAttributes(array('maxlength' => 80)); $this->add($titulo); //Input Descrição $descricao = new Textarea('descricao'); $descricao->setLabel('descriçao')->setAttributes(array('maxlength' => 150)); $this->add($descricao); //Input Titulo $texto = new Textarea('texto'); $texto->setLabel('Texto'); $this->add($texto); $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo'); $this->add($ativo); $categoria = new ObjectSelect('category'); $categoria->setLabel('Categoria')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => '\\Base\\Orm\\Entities\\Category', 'property' => 'nome', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('nome' => 'ASC'))))); $this->add($categoria); //Botao submit $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn')); $this->add($button); $this->setInputFilter(new PostFilter($categoria->getValueOptions())); }
public function __construct($name = null) { parent::__construct($name); //id $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); //titolo $this->add(array('name' => 'titolo', 'options' => array('label' => 'Titolo'), 'attributes' => array('type' => 'text', 'class' => 'form-control'))); //contenuto $nota = new Element\Textarea('contenuto'); $nota->setLabel('Contenuto'); $nota->setAttribute('class', 'ckeditor form-control'); $this->add($nota); //Background $this->add(array('name' => 'background', 'attributes' => array('type' => 'Zend\\Form\\Element\\File'), 'options' => array('label' => 'Background'))); // Posterlab $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'posterlab', 'options' => array('label' => 'Posterlab', 'empty_option' => 'Scegli un posterlab =>'), 'attributes' => array('class' => 'form-control', 'onChange' => 'javascript:caricaPosizioni()', 'id' => 'posterlabs'))); // Posizione $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'posizione', 'options' => array('label' => 'posizione', 'empty_option' => 'Scegli una posizione =>', 'disable_inarray_validator' => true), 'attributes' => array('class' => 'form-control', 'id' => 'posizioni'))); // tipo $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'tipo', 'options' => array('label' => 'Tipo', 'empty_option' => 'Scegli tipo =>'), 'attributes' => array('class' => 'form-control'))); //stato $stato = new Element\Checkbox('stato'); $stato->setLabel('Stato'); $stato->setAttribute('class', 'make-switch'); $this->add($stato); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => 'Salva', 'class' => 'btn green-haze pull-right'))); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('action', '/user/login'); $this->setAttribute('class', 'form'); $this->setAttribute('id', 'userLoginForm'); $this->setAttribute('role', 'form'); $email = new Email(); $email->setName('email')->setLabel('Email Address')->setAttribute('required', 'true'); $password = new Password(); $password->setName('password')->setLabel('Password')->setAttribute('required', 'true'); $csrf = new Csrf(); $csrf->setName('prev'); $checkbox = new Checkbox(); $checkbox->setName('remember-me'); $checkbox->setOptions(['use_hidden_element' => false, 'required' => false]); $checkbox->setChecked("checked"); $submit = new Submit(); $submit->setName('submit')->setValue('Sign In'); $this->add($email)->add($password)->add($checkbox)->add($csrf)->add($submit); foreach ($this->elements as $element) { if ($element instanceof Checkbox) { $element->setAttributes(['class' => 'custom-checkbox', 'data-toggle' => 'checkbox']); } else { if ($element instanceof Submit) { $element->setAttributes(['class' => 'btn-inverse btn-large', 'id' => 'loginSubmit']); } else { $element->setAttribute('class', 'form-control'); } } } }
public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttributes(array('method' => 'POST', 'accept-charset' => 'UTF-8', 'class' => 'form-horizontal')); //input Titulo $titulo = new Text('titulo'); $titulo->setLabel('Titulo')->setAttributes(array('id' => 'nome', 'maxlength' => 80, 'class' => 'form-control')); $this->add($titulo); //input descri��o $descricao = new Textarea('descricao'); $descricao->setLabel("Descricao")->setAttributes(array('id' => 'descricao', 'maxlength' => 150, 'class' => 'form-control')); $this->add($descricao); //input texto $texto = new Textarea('texto'); $texto->setLabel('Texto')->setAttributes(array('id' => 'texto', 'class' => 'form-control')); $this->add($texto); //input Ativo $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo')->setLabelAttributes(array('class' => 'checkbox-inline'))->setOptions(array('use_hidden_element' => true)); $this->add($ativo); //Categoria $categoria = new ObjectSelect('category'); $categoria->setLabel('Categoria')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Categoria\\Entity\\Category', 'property' => 'nome', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('nome' => 'ASC')))))->setAttributes(array('id' => 'category', 'class' => 'form-control')); $this->add($categoria); //botao submit $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn btn-default')); $this->add($button); $this->setInputFilter(new PostFilter($categoria->getValueOptions())); }
public function getForm(array $urlType) { if ($this->form) { return $this->form; } $form = new Form(); $form->setAttribute('class', 'form-horizontal'); $form->setAttribute('role', 'form'); $form->add(array('name' => 'menuId', 'type' => 'Hidden')); $form->add(array('name' => 'title', 'type' => 'text', 'options' => array('label' => 'Title'), 'attributes' => array('class' => 'form-control'))); $form->add(array('name' => 'description', 'type' => 'Textarea', 'options' => array('label' => 'Description'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'description'))); $form->add(array('name' => 'icon', 'type' => 'text', 'options' => array('label' => 'Icon'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Icon Class'))); $form->add(array('name' => 'url', 'type' => 'text', 'options' => array('label' => 'Url'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Url'))); $url_type = new Select('url_type'); $url_type->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($urlType)->setEmptyOption('-- Choose URL Type --'); $form->add($url_type); $hasDivider = new Checkbox('hasDivider'); $hasDivider->setLabel('Has divider?'); $form->add($hasDivider); $form->add(array('name' => 'parentId', 'type' => 'hidden')); $form->add(array('name' => 'priority', 'type' => 'number', 'options' => array('label' => 'Priority'), 'attributes' => array('class' => 'form-control'))); $form->setInputFilter($this->getInputFilter()); $this->form = $form; return $this->form; }
public function getForm(array $defaultStatus) { if (!$this->form) { $currencyId = new Element\Hidden(); $currencyId->setName('currencyId'); $name = new Element\Text(); $name->setLabel('Name')->setName("name")->setAttribute('class', 'form-control'); $code = new Element\Text(); $code->setLabel('Code')->setName("code")->setAttribute('class', 'form-control'); $rate = new Element\Text(); $rate->setLabel('Rate')->setName("rate")->setAttributes(array('class' => 'form-control')); $status = new Element\Select(); $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($defaultStatus); $changedRate = new Element\Checkbox(); $changedRate->setName('changedRate')->setLabel('Auto renew?')->setAttribute('class', 'form-control'); $form = new Form(); $form->setAttribute('class', 'form-horizontal'); $form->add($currencyId); $form->add($code); $form->add($name); $form->add($rate); $form->add($status); $form->add($changedRate); $this->form = $form; } return $this->form; }
/** {@inheritdoc} */ public function init() { parent::init(); $config = $this->getOption('config'); $mergeCustomFields = new Element\Checkbox('mergeCustomFields'); $mergeCustomFields->setLabel('Merge user supplied information'); $mergeCustomFields->setChecked($config->defaultMergeCustomFields); $this->add($mergeCustomFields); $mergeGroups = new Element\Checkbox('mergeGroups'); $mergeGroups->setLabel('Merge manual group assignments'); $mergeGroups->setChecked($config->defaultMergeGroups); $this->add($mergeGroups); $mergePackages = new Element\Checkbox('mergePackages'); $mergePackages->setLabel('Merge missing package assignments'); $mergePackages->setChecked($config->defaultMergePackages); $this->add($mergePackages); $submit = new \Library\Form\Element\Submit('submit'); $submit->setLabel('Merge selected clients'); $this->add($submit); // Checkboxes for "clients[]" are generated manually, without // \Zend\Form\Element. Define an input filter to have them processed. $arrayCount = new \Zend\Validator\Callback(); $arrayCount->setCallback(array($this, 'validateArrayCount'))->setMessage('At least 2 different clients have to be selected', \Zend\Validator\Callback::INVALID_VALUE); $inputFilter = new \Zend\InputFilter\InputFilter(); $inputFilter->add(array('name' => 'clients', 'required' => true, 'continue_if_empty' => true, 'filters' => array(array($this, 'clientsFilter')), 'validators' => array($arrayCount, new \Zend\Validator\Explode(array('validator' => new \Zend\Validator\Digits()))), 'error_message' => $arrayCount->getDefaultTranslator()->translate($arrayCount->getMessageTemplates()[\Zend\Validator\Callback::INVALID_VALUE]))); $this->setInputFilter($inputFilter); }
public function getForm($hasCaptcha, $url = '', $captchaPath = '') { if (!$this->form) { $form = new Form(); $txtUser = new Element\Text('username'); $txtUser->setLabel('User Name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'User name'); $password = new Element\Password('password'); $password->setLabel('Password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Password'); $remember = new Element\Checkbox('remember'); $remember->setLabel('Save authentication?')->setAttribute('class', 'form-control'); if ($hasCaptcha) { $captchaImage = new Image(); $captchaImage->setFont('./data/font/CAMBRIA.TTC')->setWidth(200)->setHeight(60)->setDotNoiseLevel(40)->setLineNoiseLevel(4)->setExpiration(90); $captchaImage->setImgUrl($url); $captchaImage->setImgDir($captchaPath); $captcha = new Element\Captcha('isHuman'); $captcha->setCaptcha($captchaImage)->setAttributes(array('class' => 'form-control')); $form->add($captcha); } $form->setAttribute('class', 'form-horizontal'); $form->add($txtUser); $form->add($password); $form->add($remember); $this->form = $form; } return $this->form; }
public function __construct($name = null, array $pais = null) { parent::__construct($name); $this->pais = $pais; $this->setAttribute('method', 'POST'); $id = new \Zend\Form\Element\Hidden('id'); $this->add($id); $nome = new Text('nome'); $nome->setLabel('Nome')->setAttribute('placeholder', 'Entre com a nome')->setAttribute('maxlength', 100)->setAttribute('size', 50)->setAttribute('autofocus', 'autofocus'); $this->add($nome); $email = new Text('email'); $email->setLabel('E-mail')->setAttribute('placeholder', 'Entre com o email')->setAttribute('maxlength', 255)->setAttribute('size', 50); $this->add($email); $celular = new Text('celular'); $celular->setLabel('Telefone')->setAttribute('placeholder', 'Entre com o telefone')->setAttribute('maxlength', 15); $this->add($celular); $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo : '); $this->add($ativo); $pai = new Select(); $pai->setLabel("Pai ")->setName("pessoa")->setOptions(array('value_options' => $pais)); $this->add($pai); $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn btn-success')); $this->add($button); }
public function __construct(ServiceLocatorInterface $sl) { parent::__construct('form-produto'); // instanciando o entity manager do doctrine $em = $sl->get('Doctrine\\ORM\\EntityManager'); // definindo variáveis $arrCategorias = array('' => 'Selecione'); $repoCategorias = $em->getRepository('Admin\\Entity\\Categoria'); $arrCategorias += $repoCategorias->getCategorias(); $categoria = new Select('categoria'); $categoria->setLabel('Categoria do produto')->setAttributes(array('id' => 'categoria', 'class' => 'form-control', 'style' => 'width: 700px', 'options' => $arrCategorias)); $this->add($categoria); $codigo = new Text('codigo'); $codigo->setLabel('Código do produto')->setAttributes(array('id' => 'codigo', 'style' => 'width: 200px', 'class' => 'form-control')); $this->add($codigo); $nome = new Text('nome'); $nome->setLabel('Nome do produto')->setAttributes(array('id' => 'nome', 'style' => 'width: 700px', 'class' => 'form-control')); $this->add($nome); $slug = new Text('slug'); $slug->setLabel('Slug do produto')->setAttributes(array('id' => 'slug', 'style' => 'width: 700px', 'class' => 'form-control')); $this->add($slug); $descricao = new Textarea('descricao'); $descricao->setLabel('Descrição')->setAttributes(array('id' => 'descricao', 'style' => 'width: 700px; height: 100px', 'class' => 'form-control')); $this->add($descricao); $peso = new Text('peso'); $peso->setLabel('Peso')->setAttributes(array('id' => 'peso', 'style' => 'width: 150px', 'class' => 'form-control')); $this->add($peso); $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo')->setAttributes(array('id' => 'ativo', 'style' => 'width: 38px', 'class' => 'form-control')); $this->add($ativo); }
public function __construct($name = null) { parent::__construct($name); //id+ $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); //categoria+ $this->add(array('name' => 'categoria', 'attributes' => array('type' => 'hidden'))); //xyz+ $this->add(array('name' => 'xyz', 'attributes' => array('type' => 'hidden'))); //nome+ $this->add(array('name' => 'nome', 'attributes' => array('type' => 'hidden'))); //sessione+ $this->add(array('name' => 'sessione', 'attributes' => array('type' => 'hidden'))); //data+ $this->add(array('name' => 'data', 'attributes' => array('type' => 'hidden'))); //messaggio+ $this->add(array('name' => 'messaggio', 'options' => array('label' => 'Messaggio'), 'attributes' => array('type' => 'text', 'class' => 'form-control'))); // Color+ $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'color', 'options' => array('label' => 'Colore', 'empty_option' => 'Scegli un colore =>'), 'attributes' => array('class' => 'form-control'))); // Posterlab+ $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'posterlab', 'options' => array('label' => 'Posterlab', 'empty_option' => 'Scegli un posterlab =>'), 'attributes' => array('class' => 'form-control'))); // tipo+ $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'tipo', 'options' => array('label' => 'Tipo', 'empty_option' => 'Scegli tipo =>'), 'attributes' => array('class' => 'form-control'))); //stato+ $stato = new Element\Checkbox('stato'); $stato->setLabel('Stato'); $stato->setAttribute('class', 'make-switch'); $this->add($stato); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => 'Salva', 'class' => 'btn green-haze pull-right'))); }
public function __construct($name = null) { parent::__construct($name); //id $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); //statosessione $this->add(array('name' => 'statosessione', 'attributes' => array('type' => 'hidden'))); //password visible $this->add(array('name' => 'password2', 'attributes' => array('type' => 'hidden'))); //titolo $this->add(array('name' => 'titolo', 'options' => array('label' => 'Titolo'), 'attributes' => array('type' => 'text', 'class' => 'form-control'))); //password $this->add(array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password', 'options' => array('label' => 'Password'), 'attributes' => array('class' => 'form-control'))); //confirmapassword $this->add(array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'confirmarPassword', 'options' => array('label' => 'Confermare Password'), 'attributes' => array('class' => 'form-control'))); // Relatori $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'relatori', 'options' => array('label' => 'Relatori', 'empty_option' => 'Scegli un relatore =>'), 'attributes' => array('class' => 'form-control'))); // Steps $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'steps', 'options' => array('label' => 'Steps', 'empty_option' => 'Scegli steps =>'), 'attributes' => array('class' => 'form-control'))); //testo $nota = new Element\Textarea('nota'); $nota->setLabel('Nota'); $nota->setAttribute('class', 'ckeditor form-control'); $this->add($nota); //Durata $this->add(array('name' => 'durata', 'options' => array('label' => 'Durata Sessione'), 'attributes' => array('type' => 'text', 'class' => 'form-control'))); //Linkedin $this->add(array('name' => 'link', 'options' => array('label' => 'Link Report'), 'attributes' => array('type' => 'text', 'class' => 'form-control'))); //stato $stato = new Element\Checkbox('stato'); $stato->setLabel('Stato'); $stato->setAttribute('class', 'make-switch'); $this->add($stato); $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => 'Salva', 'class' => 'btn green-haze pull-right'))); }
public function testSetUseHiddenElementAttributeDoesNotRenderHiddenInput() { $element = new Element\Checkbox('foo'); $element->setUseHiddenElement(false); $markup = $this->helper->render($element); $this->assertRegexp('#type="checkbox".*?(value="1")#', $markup); $this->assertNotRegexp('#type="hidden"\\s+name="foo"\\s+value="0"#', $markup); }
public function __construct($name = null, array $classificacoes = null) { parent::__construct($name); $this->classificacoes = $classificacoes; $this->setInputFilter(new PessoaFilter()); $this->setAttribute('method', 'POST'); $this->setAttribute('enctype', 'multipart/form-data'); $id = new \Zend\Form\Element\Hidden('id'); $this->add($id); $titulo = new Text('nome'); $titulo->setLabel('Nome : ')->setAttribute('placeholder', 'Entre com o nome')->setAttribute('maxlength', 100)->setAttribute('size', 50)->setAttribute('autofocus', 'autofocus'); $this->add($titulo); $classificacao = new Select(); $classificacao->setLabel("Classificacao ")->setName("classification")->setOptions(array('value_options' => $classificacoes)); $this->add($classificacao); $dataAdmissao = new Text('data_admissao'); $dataAdmissao->setLabel('Data Admissão'); $this->add($dataAdmissao); $enderecoResidencial = new Text('endereco_residencial'); $enderecoResidencial->setLabel('End. Residencial:')->setAttribute('placeholder', 'Entre com o endereço residencial')->setAttribute('maxlength', 255)->setAttribute('size', 50); $this->add($enderecoResidencial); $telefoneResidencial = new Text('telefone_residencial'); $telefoneResidencial->setLabel('Tel. Residencial'); $this->add($telefoneResidencial); $celular = new Text('celular'); $celular->setLabel('Celular'); $this->add($celular); $emailPessoal = new Text('email_pessoal'); $emailPessoal->setLabel('Email Pessoal'); $this->add($emailPessoal); $enderecoComercial = new Text('endereco_comercial'); $enderecoComercial->setLabel('End. Comercial:')->setAttribute('placeholder', 'Entre com o endereço comercial')->setAttribute('maxlength', 255)->setAttribute('size', 50); $this->add($enderecoComercial); $telefoneComercial = new Text('telefone_comercial'); $telefoneComercial->setLabel('Tel. Comercial'); $this->add($telefoneComercial); $emailComercial = new Text('email_comercial'); $emailComercial->setLabel('Email Comercial'); $this->add($emailComercial); $conjuge = new Text('conjuge'); $conjuge->setLabel('Nome do Conjuge')->setAttribute('maxlength', 100)->setAttribute('size', 50); $this->add($conjuge); $celularConjuge = new Text('celular_conjuge'); $celularConjuge->setLabel('Celular do Conjuge'); $this->add($celularConjuge); /*===========================================================================================*/ $fotografia = new File('fotografia'); $fotografia->setLabel('Fotografia')->setAttribute('id', 'fotografia'); $this->add($fotografia); /*===========================================================================================*/ $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo : '); $this->add($ativo); $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn btn-success')); $this->add($button); }
public function __construct(LicenseInterface $license) { parent::__construct('license'); $agreement = $license->getAgreement() ?: $license->getTitle(); $checkbox = new Checkbox('agreement'); $checkbox->setOptions(['use_hidden_element' => false]); $checkbox->setLabel($agreement); $checkbox->setLabelOptions(['disable_html_escape' => true]); $this->add($checkbox); }
/** {@inheritdoc} */ public function init() { parent::init(); $inputFilter = new \Zend\InputFilter\InputFilter(); // Create list of values as array because nested iteration does not work with ResultSet objects. $this->_definedValues = iterator_to_array($this->getOption('registryManager')->getValueDefinitions()); // Subform for enabling/disabling registry inspection, in addition to // the same setting in preferences. $fieldsetInspect = new \Zend\Form\Fieldset('inspect'); $inspect = new Element\Checkbox('inspect'); $inspect->setLabel('Inspect registry')->setChecked($this->getOption('config')->inspectRegistry); $fieldsetInspect->add($inspect); $this->add($fieldsetInspect); // Subform for existing values $fieldsetExisting = new \Zend\Form\Fieldset('existing'); $inputFilterExisting = new \Zend\InputFilter\InputFilter(); // Create text elements for existing values to rename them foreach ($this->_definedValues as $value) { $name = $value['Name']; $elementName = "value_{$value['Id']}_name"; $element = new Element\Text($elementName); $element->setValue($name)->setLabel($value['FullPath']); $inputFilterExisting->add(array('name' => $elementName, 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)), $this->_createBlacklistValidator($name)))); $fieldsetExisting->add($element); } $this->add($fieldsetExisting); $inputFilter->add($inputFilterExisting, 'existing'); // Subform for new value $fieldsetNew = new \Zend\Form\Fieldset('new_value'); $newName = new Element\Text('name'); $newName->setLabel('Name'); $fieldsetNew->add($newName); $newRootKey = new Element\Select('root_key'); $newRootKey->setLabel('Root key')->setAttribute('type', 'select_untranslated')->setValueOptions(\Model\Registry\Value::rootKeys())->setValue(\Model\Registry\Value::HKEY_LOCAL_MACHINE); $fieldsetNew->add($newRootKey); // Additional validation in isValid() $newSubKeys = new Element\Text('subkeys'); $newSubKeys->setLabel('Subkeys'); $fieldsetNew->add($newSubKeys); $newValue = new Element\Text('value'); $newValue->setLabel('Only this value (optional)'); $fieldsetNew->add($newValue); $submit = new \Library\Form\Element\Submit('submit'); $submit->setLabel('Change'); $fieldsetNew->add($submit); $this->add($fieldsetNew); $inputFilterNew = new \Zend\InputFilter\InputFilter(); $inputFilterNew->add(array('name' => 'name', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)), $this->_createBlacklistValidator()))); $inputFilterNew->add(array('name' => 'subkeys', 'continue_if_empty' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateEmptySubkeys'), 'message' => "Value is required and can't be empty")), array('name' => 'StringLength', 'options' => array('max' => 255))))); $inputFilterNew->add(array('name' => 'value', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255))))); $inputFilter->add($inputFilterNew, 'new_value'); $this->setInputFilter($inputFilter); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); $confirm = new Checkbox('confirm'); $confirm->setLabel('confirm.account.deletion'); $confirm->setAttribute('class', 'checkbox form-control'); $this->add($confirm); $submit = new Submit('send'); $submit->setValue('delete.account'); $submit->setAttribute('class', 'btn btn-danger'); $this->add($submit); }
public function __construct() { parent::__construct('subscription'); $subscribe = new Element\Checkbox('subscribe'); $subscribe->setName('subscribe'); $subscribe->setLabel('Add to watchlist.'); $subscribe->setChecked(true); $mailman = new Element\Checkbox('mailman'); $mailman->setName('mailman'); $mailman->setLabel('Receive notifications via email.'); $mailman->setChecked(true); $this->add($subscribe); $this->add($mailman); }
public function __construct() { parent::__construct('AddRecipeForm'); $noOfPeopleElement = new Text('NoOfPeople'); $noOfPeopleElement->setLabel('Anzahl Personen'); $this->add($noOfPeopleElement); // Add Text for kcal. //TODO: Rescrict input to integers $kcalElement = new Text('Kcal'); $kcalElement->setLabel('Anzahl Kalorien'); $this->add($kcalElement); // Add Checkbox for publicFlag $publicFlagElement = new Checkbox('PublicFlag'); $publicFlagElement->setLabel('Möchten Sie das Rezept öffentlich speichern?'); $this->add($publicFlagElement); $preparationTimeElement = new Text('PreparationTime'); $preparationTimeElement->setLabel('Vorbereitungszeit'); $this->add($preparationTimeElement); $cookingTimeElement = new Text('CookingTime'); $cookingTimeElement->setLabel('Koch- / Backzeit'); $this->add($cookingTimeElement); $restingTimeElement = new Text('RestingTime'); $restingTimeElement->setLabel('Ruhezeit'); $this->add($restingTimeElement); $types = $this->selectAllFrom('Types', 'Name'); $typeElement = new MultiCheckbox('TypeId'); $typeElement->setLabel('Rezept Typ'); //$possibleValues = array('Sommermenu','Herbstmenu','Wintermenu','Frühlingsmenu'); $typeElement->setValueOptions($types); $this->add($typeElement); $levels = $this->selectAllFrom('Levels', 'Shortname'); $levelElement = new Select('Level'); $levelElement->setLabel('Schwierigkeit'); $levelElement->setValueOptions($levels); /*array('einfach','schwierig'));*/ $levelElement->setValue($levels[0]); $this->add($levelElement); // Add steps $this->addSteps($this->getMaxNumberOfSteps()); // Add select for chosing how many steps should be displayed $stepNumbers = range(1, $this->maxNoOfSteps); $addStepSelect = new Select('StepNumber'); $addStepSelect->setLabel('Anzahl Schritte wählen'); $addStepSelect->setValueOptions($stepNumbers); $addStepSelect->setAttribute('id', 'NoOfStepSelect'); $addStepSelect->setAttribute('onchange', 'show(++this.value)'); $this->add($addStepSelect); }
public function testCheckWithCheckedValue() { $element = new CheckboxElement(); $this->assertEquals(false, $element->isChecked()); $element->setValue($element->getCheckedValue()); $this->assertEquals(true, $element->isChecked()); }
/** * Test * * @return void */ public function testRenderOptionsWithEmptyClassAndNotScalarData() { $this->element->setValueOptions(array(array('selected' => true, 'disabled' => true, 'label_attributes' => array(), 'attributes' => array()))); $markup = $this->object->render($this->element); $this->assertContains('type="checkbox"', $markup); $this->assertContains('name="foo[]"', $markup); }
/** * Load upload prevalue editor * * @return Element\Checkbox[] */ public function load() { $config = $this->getConfig(); $isMultiple = new Element\Checkbox('is_multiple'); $isMultiple->setAttributes(array('value' => isset($config['is_multiple']) ? $config['is_multiple'] : '', 'class' => 'input-checkbox', 'id' => 'is_multiple')); $isMultiple->setOptions(array('label' => 'Is Multiple', 'label_attributes' => array('class' => 'required control-label col-lg-2'))); $mimeList = new Element\MultiCheckbox('mime_list'); $array = array('image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/svg+xml', 'text/css', 'text/csv', 'text/html', 'text/javascript', 'text/plain', 'text/xml', 'video/mpeg', 'video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/x-msvideo', 'video/x-flv', 'audio/mpeg', 'audio/x-ms-wma', 'audio/vnd.rn-realaudio', 'audio/x-wav'); $options = array(); foreach ($array as $mime) { $options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($config['mime_list']) ? array() : $config['mime_list']) ? false : true); } $mimeList->setAttribute('class', 'input-checkbox'); $mimeList->setValueOptions($options); return array($isMultiple, $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('mimeList' => $mimeList))); }
public function __construct($name = null) { parent::__construct('user'); $this->setAttribute('method', 'post'); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); $element = new Element\Text('name'); $element->setAttributes(array('size' => '30', 'class' => 'form-control', 'placeholder' => 'name')); $this->add($element); $element = new Element\Text('setting'); $element->setAttributes(array('size' => '30', 'class' => 'form-control', 'placeholder' => 'setting')); $this->add($element); $element = new Element\Checkbox('is_active'); $element->setAttributes(array('size' => '30', 'placeholder' => 'is active', 'label' => 'is active')); $this->add($element); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send', 'id' => 'submitbutton', 'class' => 'form-control btn btn-primary'))); }
/** * Test * * @return void */ public function testRenderWithClass() { $this->element->setValue('checked'); $this->element->setAttribute('class', 'input-checkbox'); $markup = $this->object->render($this->element); $this->assertContains('checked="checked"', $markup); $this->assertContains('class="input-checkbox"', $markup); }
/** * Form initialization */ public function init() { $this->loadDefaultDecorators(); $this->setLegend('New layout'); $this->addDecorator('fieldset'); $this->setMethod('POST'); $element = new Element\Text('title'); $element->setLabel('Title:')->setRequired(true); $this->addElement($element); $themes = $this->themesModel->getThemesPaginator(1, 10000); $themesList = array(); foreach ($themes as $theme) { $themesList[$theme->getId()] = $theme->getTitle(); } $element = new Element\Select('theme_id'); $element->setLabel('Theme:')->addMultiOptions($themesList)->setRequired(true); $this->addElement($element); $element = new Element\Text('name'); $element->setLabel('Layout file:')->setRequired(true); $this->addElement($element); $element = new Element\Checkbox('published'); $element->setLabel('Published:'); $this->addElement($element); if ($this->locator->instanceManager()->hasAlias('sysmap-service')) { $navigator = $this->locator->get('sysmap-service')->getMapFormElement(); if ($navigator instanceof \Zly\Form\Element\Tree) { $navigator->setName('map_id'); $navigator->setMultiple(true); $navigator->setRequired(); $this->addElement($navigator); } } $element = new Element\Hidden('module'); $element->removeDecorator('Label')->removeDecorator('HtmlTag')->setValue($this->_defaultValue); $this->addElement($element); $element = new Element\Hidden('controller'); $element->removeDecorator('Label')->setValue($this->_defaultValue)->removeDecorator('HtmlTag'); $this->addElement($element); $element = new Element\Hidden('action'); $element->removeDecorator('Label')->setValue($this->_defaultValue)->removeDecorator('HtmlTag'); $this->addElement($element); $element = new Element\Submit('submit'); $element->setLabel('Save')->setIgnore(true); $this->addElement($element); }
public function addElements() { $this->setAttributes(array('method' => 'post', 'class' => 'form-horizontal', 'action' => '/admin/users/save')); $usrId = new Element\Hidden('usr_id'); $name = new Element\Text('name'); $name->setName('name')->setAttribute('placeholder', 'Nome do usuário')->setLabel('Nome do usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $username = new Element\Text('username'); $username->setName('username')->setAttributes(array('id' => 'username', 'placeholder' => 'Usuário'))->setLabel('Usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $password = new Element\Password('password'); $password->setName('password')->setAttributes(array('id' => 'password', 'placeholder' => 'Senha'))->setLabel('Senha')->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $role = new Element\Select('role'); $role->setName('role')->setLabel('Perfil de usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label'))->setValueOptions(array('' => 'Escolha um perfil', 'admin' => 'Administrador', 'redator' => 'Redator')); $valid = new Element\Checkbox('valid'); $valid->setName('valid')->setLabel('Ativar usuário')->setLabelAttributes(array('class' => 'lbl')); $submit = new Element\Submit('submit'); $submit->setAttribute('value', 'Salvar')->setAttribute('class', 'btn btn-primary'); $this->add($usrId)->add($name)->add($username)->add($password)->add($role)->add($valid)->add($submit); }
public function __construct($roleName, array $permissions, Acl $acl) { parent::__construct(); $this->setAttribute('method', 'post'); $roles = $acl->getRoles(); $parentPermissions = []; foreach ($roles as $role) { if ($acl->inheritsRole($roleName, $role, true)) { foreach ($permissions as $permissionId => $permission) { if ($acl->isAllowed($role, $permission)) { $parentPermissions[$permissionId] = $permissionId; } } } } $permissionGroups = []; foreach ($permissions as $permissionId => $permission) { $fragments = explode('/', $permission); $groupName = reset($fragments); if (!array_key_exists($groupName, $permissionGroups)) { $permissionGroups[$groupName] = []; } $permissionGroups[$groupName][] = $permissionId; } foreach ($permissionGroups as $groupName => $groupPermissions) { foreach ($groupPermissions as $permission) { $permissionCheck = new Checkbox($permission); $permissionCheck->setLabel($permissions[$permission]); if (array_key_exists($permission, $parentPermissions)) { $permissionCheck->setValue(true); $permissionCheck->setAttribute('disabled', true); } $this->add($permissionCheck); if (!array_key_exists($groupName, $this->permissionGroups)) { $this->permissionGroups[$groupName] = []; } $this->permissionGroups[$groupName][] = $permissionCheck; } } $submit = new Submit('save'); $submit->setValue('save'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new CheckboxElement(); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); $expectedClasses = array('Zend\\Validator\\InArray'); foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertTrue(in_array($class, $expectedClasses), $class); switch ($class) { case 'Zend\\Validator\\InArray': $this->assertEquals(array($element->getCheckedValue(), $element->getUncheckedValue()), $validator->getHaystack()); break; default: break; } } }