/** * @param mixed $value * @throws \Zend\Form\Exception\InvalidArgumentException * @return void|\Zend\Form\Element */ public function setValue($value) { if (is_string($value)) { try { $value = new PhpDateTime($value); } catch (Exception $e) { throw new InvalidArgumentException('Value should be a parsable string or an instance of \\DateTime'); } } if (is_null($value)) { $value = new PhpDateTime(); } if ($value instanceof PhpDateTime) { $value = array('year' => $value->format('Y'), 'month' => $value->format('m'), 'day' => $value->format('d'), 'hour' => $value->format('H'), 'minute' => $value->format('i'), 'second' => $value->format('s')); } if (!isset($value['second'])) { $value['second'] = '00'; } $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); $this->dayElement->setValue($value['day']); $this->hourElement->setValue($value['hour']); $this->minuteElement->setValue($value['minute']); $this->secondElement->setValue($value['second']); }
/** * @param mixed $value * @return void|\Zend\Form\Element */ public function setValue($value) { if ($value instanceof PhpDateTime) { $value = array('year' => $value->format('Y'), 'month' => $value->format('m')); } $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); }
/** * {@inheritDoc} */ public function setValue($value) { if ($this->isMultiple()) { if ($value instanceof \Traversable) { $value = ArrayUtils::iteratorToArray($value); } elseif (!$value) { return parent::setValue([]); } elseif (!is_array($value)) { $value = (array) $value; } return parent::setValue(array_map(Locale::class . '::canonicalize', $value)); } return parent::setValue(Locale::canonicalize($value)); }
/** * {@inheritDoc} */ public function setValue($value) { $multiple = $this->getAttribute('multiple'); if (true === $multiple || 'multiple' === $multiple) { if ($value instanceof \Traversable) { $value = ArrayUtils::iteratorToArray($value); } elseif ($value == null) { return parent::setValue(array()); } elseif (!is_array($value)) { $value = (array) $value; } return parent::setValue(array_map(array($this->getProxy(), 'getValue'), $value)); } return parent::setValue($this->getProxy()->getValue($value)); }
/** * @param string|array|\ArrayAccess|PhpDateTime $value * @throws \Zend\Form\Exception\InvalidArgumentException * @return void|\Zend\Form\Element */ public function setValue($value) { if (is_string($value)) { try { $value = new PhpDateTime($value); } catch (Exception $e) { throw new InvalidArgumentException('Value should be a parsable string or an instance of DateTime'); } } if ($value instanceof PhpDateTime) { $value = array('year' => $value->format('Y'), 'month' => $value->format('m'), 'day' => $value->format('d')); } $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); $this->dayElement->setValue($value['day']); }
public function initSharedUsersSelect($uploadId) { $upload = $this->uploadTable->getById($uploadId); $sharedUsers = $this->uploadTable->getSharedUsers($uploadId); foreach ($sharedUsers as $sharedUser) { $userSelected[] = $sharedUser->user_id; } // \Zend\Debug\Debug::dump($sharedUsers); $users = $this->userTable->fetchAll(); foreach ($users as $user) { if ($user->getId() != $upload->getUserId()) { $usersOptions[$user->getId()] = $user->getEmail(); } } $options = array('label' => 'Пользователи', 'value_options' => $usersOptions, 'disable_inarray_validator' => true, "attributes" => array("value" => 0)); $select = new Element\Select('shared_user_ids'); $select->setOptions($options); $select->setValue($userSelected); $select->setAttribute('multiple', 'multiple'); $this->add($select); }
/** * Load Image cropper prevalue editor * * @return string */ public function load() { $config = $this->getConfig(); $resizeOption = new Element\Select('resize_option'); $resizeOption->setValue(empty($config['resize_option']) ? 'auto' : $config['resize_option'])->setAttribute('class', 'form-control')->setAttribute('id', 'resize-option')->setLabel('Resize option')->setLabelAttributes(array('class' => 'col-lg-2'))->setValueOptions(array('auto' => 'auto', 'crop' => 'crop')); $backgroundOption = new Element\Text('background'); $backgroundOption->setValue(empty($config['background']) ? '' : $config['background'])->setAttribute('class', 'form-control')->setAttribute('id', 'background')->setLabel('Background color')->setLabelAttributes(array('class' => 'col-lg-2')); $mimeList = new Element\MultiCheckbox('mime_list'); $mimeList->setAttribute('class', 'input-checkbox')->setLabel('Mime list')->setLabelAttributes(array('class' => 'col-lg-2')); $array = array('image/gif', 'image/jpeg', 'image/png'); $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->setValueOptions($options); $sizeElements = array(); $idx = 0; if (!empty($config['size'])) { foreach ($config['size'] as $idx => $size) { $elementSizeName = new Element\Text('size[' . $idx . '][name]'); $elementSizeName->setValue($size['name'])->setAttribute('class', 'form-control')->setAttribute('id', 'name' . $idx)->setLabel('Name'); $elementWidth = new Element\Text('size[' . $idx . '][width]'); $elementWidth->setValue($size['width'])->setAttribute('class', 'form-control')->setAttribute('id', 'width' . $idx)->setLabel('Width'); $elementHeight = new Element\Text('size[' . $idx . '][height]'); $elementHeight->setValue($size['height'])->setAttribute('class', 'form-control')->setAttribute('id', 'height' . $idx)->setLabel('Height'); $sizeElements[] = array($elementSizeName, $elementWidth, $elementHeight); } $idx++; } $elementSizeName = new Element\Text('size[#{idx}][name]'); $elementSizeName->setAttribute('id', 'name#{idx}')->setAttribute('class', 'form-control')->setLabel('Name'); $elementWidth = new Element\Text('size[#{idx}][width]'); $elementWidth->setLabel('Width')->setAttribute('class', 'form-control')->setAttribute('id', 'width#{idx}'); $elementHeight = new Element\Text('size[#{idx}][height]'); $elementHeight->setLabel('Height')->setAttribute('class', 'form-control')->setAttribute('id', 'height#{idx}'); $template = array($elementSizeName, $elementWidth, $elementHeight); return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => array('resize-option' => $resizeOption, 'background' => $backgroundOption, 'mime' => $mimeList, 'size' => $sizeElements, 'size-template' => $template))); }
public function __construct(EntityManager $em, OrmPublicador $publicador = null, OrmLogin $orm = null) { parent::__construct("formLogin"); // var_dump($option); // exit(); /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtEmail = new Element\Email("email"); $txtEmail->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'data-parsley-trigger' => 'change', 'required' => 'true')); /* * txtSenha */ $txtSenha = new Element\Password("senha"); $txtSenha->setAttributes(array('id' => "senha", 'class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'required' => 'true', "data-parsley-trigger" => "change", "data-parsley-length" => "[6, 20]")); /* * txtSenhaConfirma */ $txtSenhaConfirma = new Element\Password("senhaconfirmar"); $txtSenhaConfirma->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'required' => 'true', "data-parsley-trigger" => "change", "data-parsley-equalto" => "#senha")); /* * cmbPublicador */ $dao = $em->getRepository('Stj\\Entity\\OrmPublicador'); if (empty($publicador)) { $lista = $dao->findAll(); } else { $lista = $dao->ListALLWhere($publicador->getGrupo()->getCongregacao()->getId()); } $option = array(); foreach ($lista as $key => $value) { $publicador = new OrmPublicador(); $publicador = $value; $option[$publicador->getId()] = $publicador->getNome(); } $cmbPublicador = new Element\Select('publicador'); $cmbPublicador->setValueOptions($option); $cmbPublicador->setEmptyOption("Selecionar"); $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * cmbNivel */ $dao = $em->getRepository('Stj\\Entity\\OrmNivel'); $lista = $dao->ListALL(FALSE); $option = array(); foreach ($lista as $key => $value) { $nivel = new OrmNivel(); $nivel = $value; $option[$nivel->getId()] = $nivel->getNome(); } $cmbNivel = new Element\Select('nivel'); $cmbNivel->setValueOptions($option); $cmbNivel->setEmptyOption("Selecionar"); $cmbNivel->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtEmail->setValue($orm->getEmail()); $cmbPublicador->setValue($orm->getPublicador()->getId()); $cmbNivel->setValue($orm->getNivel()->getId()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtEmail); $this->add($txtSenha); $this->add($txtSenhaConfirma); $this->add($cmbPublicador); $this->add($cmbNivel); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }
/** * Add property sub form * * @param mixed $property \Gc\Property\Model|array * * @return DocumentType */ public function addProperty($property) { if (!is_array($property) and !$property instanceof Property\Model) { return $this; } $fieldsets = $this->getProperties(); $name = new Element\Text('name'); $identifier = new Element('identifier'); $tab = new Element\Select('tab'); $tab->setAttribute('class', 'select-tab')->setValueOptions(array()); $datatype = new Element\Select('datatype'); $datatype->setAttribute('class', 'select-datatype')->setValueOptions($this->datatypeCollection->getSelect()); $description = new Element\Text('description'); $required = new Element\Checkbox('required'); $required->setCheckedValue('1')->setAttribute('id', 'required')->setAttribute('class', 'input-checkbox'); $propertyId = new Element\Hidden('property_id'); if ($property instanceof Property\Model) { $name->setValue($property->getName()); $identifier->setValue($property->getIdentifier()); $tab->setValue($property->getTabId()); $datatype->setValue($property->getDatatypeId()); $description->setValue($property->getDescription()); $required->setValue((string) $property->isRequired()); $propertyId->setValue($property->getId()); $propertyFieldsetName = $property->getId(); } else { $name->setValue($property['name']); $identifier->setValue($property['identifier']); $tab->setValue($property['tab']); $datatype->setValue($property['datatype']); $description->setValue($property['description']); $required->setValue((string) (!empty($property['isRequired']))); $propertyId->setValue(str_replace('property', '', $property['id'])); $propertyFieldsetName = $property['id']; } $propertyForm = new FieldSet($propertyFieldsetName); $propertyForm->add($propertyId); $propertyForm->add($name); $propertyForm->add($identifier); $propertyForm->add($tab); $propertyForm->add($datatype); $propertyForm->add($description); $propertyForm->add($required); $fieldsets->add($propertyForm); $this->getInputFilter()->get('properties')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'tab' => array('name' => 'tab', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'datatype' => array('name' => 'datatype', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'required' => array('name' => 'required', 'required' => false, 'allow_empty' => true)), $propertyFieldsetName); return $this; }
public function testCanMarkOptionsAsSelectedWhenEmptyOptionOrZeroValueSelected() { $element = new SelectElement('foo'); $element->setEmptyOption('empty'); $element->setValueOptions(array(0 => 'label0', 1 => 'label1')); $element->setValue(''); $markup = $this->helper->render($element); $this->assertContains('<option value="" selected="selected">empty</option>', $markup); $this->assertContains('<option value="0">label0</option>', $markup); $element->setValue('0'); $markup = $this->helper->render($element); $this->assertContains('<option value="">empty</option>', $markup); $this->assertContains('<option value="0" selected="selected">label0</option>', $markup); }
/** * Builds repeat fieldset and returns it. * * @return Fieldset */ public function getRepeatFieldset() { $repeatFieldset = new Fieldset('repeat'); // Picker field $picker = new Element\Select('picker'); $picker->setLabel('Repeat'); $picker->setAttributes(array('class' => 'form-control repeat', 'autocomplete' => 'off')); $picker->setValueOptions($this->_repeatOptions); $picker->setValue(self::DAILY); $repeatFieldset->add($picker); // Attach "child" fieldsets $repeatFieldset->add($this->getRepeatWeeklyFieldset()); $repeatFieldset->add($this->getRepeatMonthlyFieldset()); $repeatFieldset->add($this->getRepeatYearlyFieldset()); return $repeatFieldset; }
public function __construct(EntityManager $em, OrmPublicador $tipoPrivilegio = null, OrmPrivilegios $orm = null) { parent::__construct("formPrivilegios"); // var_dump($option); // exit(); /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtDataInicio = new Element\Text("dataInicio"); $txtDataInicio->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10', 'required' => 'true')); $txtDataTermino = new Element\Text("dataTermino"); $txtDataTermino->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * cmbPublicador */ $dao = $em->getRepository('Stj\\Entity\\OrmPublicador'); if (empty($tipoPrivilegio)) { $lista = $dao->findAll(); } else { $lista = $dao->ListALLWhere($tipoPrivilegio->getId()); } $option = array(); foreach ($lista as $key => $value) { $tipoPrivilegio = new OrmPublicador(); $tipoPrivilegio = $value; $option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome(); } $cmbPublicador = new Element\Select('publicador'); $cmbPublicador->setValueOptions($option); $cmbPublicador->setEmptyOption("Selecionar"); $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * cmbPrivilegio */ $dao = $em->getRepository('Stj\\Entity\\OrmTipoPrivilegios'); $lista = $dao->findAll(); $option = array(); foreach ($lista as $key => $value) { $tipoPrivilegio = new OrmTipoPrivilegios(); $tipoPrivilegio = $value; $option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome(); } $cmbPrivilegio = new Element\Select('privilegio'); $cmbPrivilegio->setValueOptions($option); $cmbPrivilegio->setEmptyOption("Selecionar"); $cmbPrivilegio->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtDataInicio->setValue($orm->getDataInicio() != "" ? $orm->getDataInicio()->format('d/m/Y') : ""); $txtDataTermino->setValue($orm->getDataTermino() != "" ? $orm->getDataTermino()->format('d/m/Y') : ""); $cmbPrivilegio->setValue($orm->getTipoPrivilegio()->getId()); $cmbPublicador->setValue($orm->getPublicador()->getId()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtDataInicio); $this->add($txtDataTermino); $this->add($cmbPublicador); $this->add($cmbPrivilegio); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }
public function __construct(EntityManager $em, $publicador = null, OrmGrupo $orm = null) { parent::__construct("formGrupo"); $dao = $em->getRepository('Stj\\Entity\\OrmCongregacao'); $lista = $dao->findAll(); $option = array(); foreach ($lista as $key => $value) { $congregacao = new OrmCongregacao(); $congregacao = $value; $option[$congregacao->getId()] = $congregacao->getNome(); } // var_dump($option); // exit(); /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtNome = new Element\Text("nome"); $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ0-9]+((\\s[aA-zZ0-9]+)+)?$', 'required' => 'true')); /* * cmbCongregacao */ $cmbCongregacao = new Element\Select('congregacao'); $cmbCongregacao->setValueOptions($option); $cmbCongregacao->setEmptyOption("Escolha a congregação"); $cmbCongregacao->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * txtCep */ $txtCep = new Element\Text("cep"); $txtCep->setAttributes(array('class' => 'form-control', 'placeholder' => 'XXXXXXXX', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]{2}[0-9]{3}[0-9]{3}$/', 'max-length' => '8')); /* * txtNumero */ $txtNumero = new Element\Text("numero"); $txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6')); /* * txtLogradouro */ $txtLogradouro = new Element\Text("logradouro"); $txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtComplemento */ $txtComplemento = new Element\Text("complemento"); $txtComplemento->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtBairro */ $txtBairro = new Element\Text("bairro"); $txtBairro->setAttributes(array('class' => 'form-control')); /* * txtCidade */ $txtCidade = new Element\Text("cidade"); $txtCidade->setAttributes(array('class' => 'form-control')); /* * txtUf */ $txtUf = new Element\Text("uf"); $txtUf->setAttributes(array('class' => 'form-control', 'max-length' => '2')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtNome->setValue($orm->getNome()); $cmbCongregacao->setValue($orm->getCongregacao()->getId()); $txtCep->setValue($orm->getCep()); $txtNumero->setValue($orm->getNumero()); $txtLogradouro->setValue($orm->getLogradouro()); $txtComplemento->setValue($orm->getComplemento()); $txtBairro->setValue($orm->getBairro()); $txtCidade->setValue($orm->getCidade()); $txtUf->setValue($orm->getUf()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtNome); if (empty($publicador)) { $this->add($cmbCongregacao); } $this->add($txtCep); $this->add($txtNumero); $this->add($txtLogradouro); $this->add($txtComplemento); $this->add($txtBairro); $this->add($txtCidade); $this->add($txtUf); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }
/** * {@inheritDoc} */ public function setValue($value) { return parent::setValue($this->getProxy()->getValue($value)); }
/** * @param string|int $value * @return self */ public function setValue($value) { $this->insertSelectedClientIfRequired($value); return parent::setValue($value); }
public function __construct(EntityManager $em, OrmPublicador $orm = null, $publicador = null) { parent::__construct("formPublicador"); $dao = $em->getRepository('Stj\\Entity\\OrmGrupo'); if ($publicador == null) { $lista = $dao->findAll(); } else { $lista = $dao->ListALL(FALSE, $publicador->getGrupo()->getCongregacao()); } $option = array(); $grupoarray = array(); $i = 0; $nomeCongregacao = ""; foreach ($lista as $key => $value) { $grupo = new OrmGrupo(); $grupo = $value; if ($nomeCongregacao != "") { if ($grupo->getCongregacao()->getNome() == $nomeCongregacao) { $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } else { $option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome()); $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } } else { $option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome()); $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } $nomeCongregacao = $grupo->getCongregacao()->getNome(); } /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtNome = new Element\Text("nome"); $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Publicador', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true')); /* * cmbGrupo */ $cmbGrupo = new Element\Select('grupo'); $cmbGrupo->setValueOptions($option); $cmbGrupo->setEmptyOption("Escolha o grupo"); $cmbGrupo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * cmbClasse */ $cmbClasse = new Element\Select('classe'); $cmbClasse->setValueOptions(array('OO' => 'Outra Ovelha', 'U' => 'Ungido')); $cmbClasse->setEmptyOption("Escolha a classe"); $cmbClasse->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * cmbSexo */ $cmbSexo = new Element\Select('sexo'); $cmbSexo->setValueOptions(array('M' => 'Masculino', 'F' => 'Feminino')); $cmbSexo->setEmptyOption("Escolha o sexo"); $cmbSexo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * txtdataNascimento */ $txtNascimento = new Element\Text("nascimento"); $txtNascimento->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * txtdataEmissao */ $txtEmissao = new Element\Text("emissao"); $txtEmissao->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * txtTelefone */ $txtTelefone = new Element\Text("telefone"); $txtTelefone->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)1234-1234', 'max-length' => '13', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{4}-[0-9]{4}")); /* * txtCelular */ $txtCelular = new Element\Text("celular"); $txtCelular->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)12345-1234', 'max-length' => '14', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{5}-[0-9]{4}")); /* * txtCep */ $txtCep = new Element\Text("cep"); $txtCep->setAttributes(array('class' => 'form-control', 'placeholder' => 'XXXXXXXX', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]{2}[0-9]{3}[0-9]{3}$/', 'max-length' => '8')); /* * txtNumero */ $txtNumero = new Element\Text("numero"); $txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6')); /* * txtLogradouro */ $txtLogradouro = new Element\Text("logradouro"); $txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtComplemento */ $txtComplemento = new Element\Text("complemento"); $txtComplemento->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtBairro */ $txtBairro = new Element\Text("bairro"); $txtBairro->setAttributes(array('class' => 'form-control')); /* * txtCidade */ $txtCidade = new Element\Text("cidade"); $txtCidade->setAttributes(array('class' => 'form-control')); /* * txtUf */ $txtUf = new Element\Text("uf"); $txtUf->setAttributes(array('class' => 'form-control', 'max-length' => '2')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtNome->setValue($orm->getNome()); $cmbGrupo->setValue($orm->getGrupo()->getId()); $cmbClasse->setValue($orm->getClasse()); $cmbSexo->setValue($orm->getSexo()); if ($orm->getDtNascimento() != "") { $txtNascimento->setValue($orm->getDtNascimento()->format('d-m-Y')); } if ($orm->getDtEmissao() != "") { $txtEmissao->setValue($orm->getDtEmissao()->format('d-m-Y')); } $txtTelefone->setValue($orm->getTel()); $txtCelular->setValue($orm->getCel()); $txtCep->setValue($orm->getCep()); $txtNumero->setValue($orm->getNumero()); $txtLogradouro->setValue($orm->getLogradouro()); $txtComplemento->setValue($orm->getComplemento()); $txtBairro->setValue($orm->getBairro()); $txtCidade->setValue($orm->getCidade()); $txtUf->setValue($orm->getUf()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtNome); $this->add($cmbGrupo); $this->add($cmbClasse); $this->add($cmbSexo); $this->add($txtNascimento); $this->add($txtEmissao); $this->add($txtTelefone); $this->add($txtCelular); $this->add($txtCep); $this->add($txtNumero); $this->add($txtLogradouro); $this->add($txtComplemento); $this->add($txtBairro); $this->add($txtCidade); $this->add($txtUf); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->add($cmbGrupo); $this->setAttributes(array('id' => 'form', 'action' => '/Publicador/Salvar', 'data-parsley-validate' => NULL)); }
private function addStep($index) { $stepIdElement = new Hidden('StepId' . $index); $stepIdElement->setValue($index); $this->add($stepIdElement); $quantityElement = new Text('StepQuantityValue' . $index); $quantityElement->setLabel('Menge'); $quantityElement->setAttribute('id', 'StepQuantityValue' . $index); $this->add($quantityElement); $units = $this->selectAllFrom('Units', 'Name'); $unitElement = new Select('StepUnit' . $index); $unitElement->setValueOptions($units); // need to set default value. otherwise null is saved. $unitElement->setValue(0); $unitElement->setAttribute('id', 'StepUnit' . $index); $this->add($unitElement); $ingredients = $this->selectAllFrom('Ingredients', 'Name'); $ingredientElement = new Select('StepIngredient' . $index); $ingredientElement->setValueOptions($ingredients); //just set any default value. inserting ingredients has to be workes out anyway $ingredientElement->setValue(0); $ingredientElement->setAttribute('id', 'StepIngredient' . $index); $this->add($ingredientElement); $textElement = new Textarea('StepText' . $index); $textElement->setAttribute('id', 'StepText' . $index); $this->add($textElement); }
public function __construct(EntityManager $em, OrmRelatorio $orm = null) { parent::__construct("formRelatorio"); /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtAno */ $option = array(); $ano = 0; if (date("m") >= 9) { $ano = 1; } $ano = $ano + date("Y"); $option[$ano] = $ano; $option[$ano - 1] = $ano - 1; $cmbAno = new Element\Select('ano'); $cmbAno->setValueOptions($option); $cmbAno->setEmptyOption("Escolha o ano"); $cmbAno->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * txtMes */ setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese'); date_default_timezone_set('America/Sao_Paulo'); $option = array(); for ($index = 1; $index < 13; $index++) { $option[$index] = strftime("%B", strtotime(date("Y") . "/" . $index . "/01")); } $cmbMes = new Element\Select('mes'); $cmbMes->setValueOptions($option); $cmbMes->setEmptyOption("Escolha o ano"); $cmbMes->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * cmbPublicador */ $dao = $em->getRepository('Stj\\Entity\\OrmPublicador'); $lista = $dao->findAll(); $option = array(); foreach ($lista as $key => $value) { $congregacao = new OrmCongregacao(); $congregacao = $value; $option[$congregacao->getId()] = $congregacao->getNome(); } $cmbPublicador = new Element\Select('publicador'); $cmbPublicador->setValueOptions($option); $cmbPublicador->setEmptyOption("Escolha o publicador"); $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * txtLivros */ $txtPublicacoes = new Element\Number("publicacoes"); $txtPublicacoes->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "3", 'required' => 'true')); /* * $txtVideos */ $txtVideos = new Element\Number("videos"); $txtVideos->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "3", 'required' => 'true')); /* * $txtPublicacoes */ $txtHoras = new Element\Text("horas"); $txtHoras->setAttributes(array('class' => 'form-control', 'placeholder' => 'HH:MM', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+\\:[0-9]{2}$/', 'data-parsley-maxlength' => "6", 'required' => 'true')); /* * txtRevisitas */ $txtRevisitas = new Element\Number("revisitas"); $txtRevisitas->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "2", 'required' => 'true')); /* * txtEstudos */ $txtEstudos = new Element\Number("estudos"); $txtEstudos->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "2", 'required' => 'true')); /* * txtObs */ $txtObs = new Element\Textarea("obs"); $txtObs->setAttributes(array('class' => 'form-control', 'placeholder' => 'Digites suas observações aqui')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $cmbAno->setValue($orm->getAno()); $cmbMes->setValue($orm->getMes()); $cmbPublicador->setValue($orm->getPublicador()->getId()); $txtPublicacoes->setValue($orm->getPublicacoes()); $txtVideos->setValue($orm->getVideos()); $txtHoras->setValue($orm->getHoras()); $txtRevisitas->setValue($orm->getRevisitas()); $txtEstudos->setValue($orm->getEstudos()); } // Adiciona componetes no form $this->add($txtId); // $this->add(); $this->add($cmbAno); $this->add($cmbMes); $this->add($cmbPublicador); $this->add($txtPublicacoes); $this->add($txtVideos); $this->add($txtHoras); $this->add($txtRevisitas); $this->add($txtEstudos); $this->add($txtObs); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }