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); }
function __construct() { parent::__construct('console_address'); $element_id = new Element\Hidden('id'); $element_id->setValue(''); $this->add($element_id); $this->add(array('name' => 'username', 'type' => 'Text')); $this->add(array('name' => 'domain', 'type' => 'Text')); $this->add(array('name' => 'nickname', 'type' => 'Text')); $element_sex = new Element\Select('sex'); $element_sex->setValueOptions(array(self::ADDRESS_SEX_BOY => '男性', self::ADDRESS_SEX_GIRL => '女性')); $this->add($element_sex); $this->add(array('name' => 'submit', 'type' => 'Submit')); /** * Setting up inputFilter */ $input_id = new Input('id'); $input_id->setRequired(false)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)))->attach(new \Zend\Validator\Digits()); $input_username = new Input('username'); $input_username->setRequired(true)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 18)))->attach(new \Zend\Validator\Digits()); $input_filter = new InputFilter(); $input_filter->add($input_id); $input_filter->add($input_username); $this->setInputFilter($input_filter); }
/** * @outputBuffering disabled */ public function testCanRenderFieldsets() { $this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/'); $form = new NetsensiaForm(); $form->addHidden('test1', 'testvalue'); $hidden = new Element\Hidden('asdasd'); $hidden->setValue('123'); $form->add($hidden); $element1 = new Text('testelement1'); $element1->setLabel('Test Element'); $element1->setAttribute('icon', 'pencil'); $element2 = new Text('testelement2'); $element2->setLabel('Test Element 2'); $element2->setAttribute('icon', 'pencil'); $fieldset1 = new Fieldset('testfieldset1'); $fieldset1->add($element1); $fieldset2 = new Fieldset('testfieldset2'); $fieldset2->add($element2); $form->add($fieldset1); $form->add($fieldset2); $helpers = new HelperPluginManager(); $helpers->setService('formElement', new FormElement()); $view = new PhpRenderer(); $view->setHelperPluginManager($helpers); $viewHelper = new BootstrapForm(); $viewHelper->setView($view); $viewHelper($form, 'testform', '/'); }
/** * @param $which * @return $this */ public function setWhich($which) { $hidden = new Form\Element\Hidden('which'); $hidden->setLabel(' '); $hidden->setValue($which); $this->add($hidden); return $this; }
public function getHiddenElement(ElementInterface $element) { if ($element instanceof Hidden) { return $element; } $name = $element->getName(); $value = $element->getValue(); $hidden = new Hidden($name); $hidden->setValue($value); return $hidden; }
/** * {@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; }
public function __construct(OrmCongregacao $orm = null) { parent::__construct("formProduto"); $txtId = new Element\Hidden("id"); $txtNome = new Element\Text("nome"); $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome da Congregação', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true')); $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', 'required' => 'true')); $txtNumero = new Element\Text("numero"); $txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6', 'required' => 'true')); $txtLogradouro = new Element\Text("logradouro"); $txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...', 'required' => 'true')); $txtBairro = new Element\Text("bairro"); $txtBairro->setAttributes(array('class' => 'form-control', 'required' => 'true')); $txtCidade = new Element\Text("cidade"); $txtCidade->setAttributes(array('class' => 'form-control', 'required' => 'true')); $txtUf = new Element\Text("uf"); $txtUf->setAttributes(array('class' => 'form-control', 'max-length' => '2', 'required' => 'true')); $iToken = new Element\Csrf("iToken"); $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 = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); if ($orm != null) { $txtId->setValue($orm->getId()); $txtNome->setValue($orm->getNome()); $txtCep->setValue($orm->getCep()); $txtNumero->setValue($orm->getNumero()); $txtLogradouro->setValue($orm->getLogradouro()); $txtBairro->setValue($orm->getBairro()); $txtCidade->setValue($orm->getCidade()); $txtUf->setValue($orm->getUf()); } // $this->add($txtId); $this->add($txtNome); $this->add($txtCep); $this->add($txtNumero); $this->add($txtLogradouro); $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)); }
function __construct() { parent::__construct('console_task'); $element_id = new Element\Hidden('id'); $element_id->setValue(''); $this->add($element_id); $this->add(array('name' => 'title', 'type' => 'Text')); $this->add(array('name' => 'submit', 'type' => 'Submit')); /** * Setting up inputFilter */ $input_id = new Input('id'); $input_id->setRequired(false)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)))->attach(new \Zend\Validator\Digits()); $input_title = new Input('title'); $input_title->setRequired(true)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 255))); $input_filter = new InputFilter(); $input_filter->add($input_id); $input_filter->add($input_title); $this->setInputFilter($input_filter); }
public function __construct($name = null) { parent::__construct('promoForm'); $this->setAttribute('method', 'post'); $publicidad = new Element\Hidden('ID_PUBLICIDAD'); $publicidad->setValue('0'); $sponsor = new Element\Hidden('ID_CAMPANA'); $sponsor->setValue('0'); $nombre = new Element\Text('NOMBRE'); $nombre->setLabel('Nombre de la publicidad: '); $imagen = new Element\File('IMAGEN'); $imagen->setLabel('Imagen de la publicidad: '); $descripcion = new Element\Textarea('DESCRIPCION'); $descripcion->setLabel('Descripcion: '); $this->add($publicidad); $this->add($imagen); $this->add($sponsor); $this->add($nombre); $this->add($descripcion); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Agregar publicidad', 'id' => 'submitbutton'))); }
public function __construct($name = null) { parent::__construct('campaignForm'); $this->setAttribute('method', 'post'); $sponsor = new Element\Hidden('ID_SPONSOR'); $sponsor->setValue('0'); $nombre = new Element\Text('NOMBRE'); $nombre->setLabel('Nombre de la campaña: '); $descripcion = new Element\Textarea('DESCRIPCION'); $descripcion->setLabel('Descripcion: '); $slogan = new Element\Textarea('SLOGAN'); $slogan->setLabel('Slogan de la campaña: '); $fecha_inicio = new Element\Date('FECHA_INICIO'); $fecha_inicio->setLabel('Fecha de inicio de la campaña: ')->setAttributes(array('min' => '2012-01-01', 'max' => '2080-01-01', 'step' => '1')); $fecha_fin = new Element\Date('FECHA_FIN'); $fecha_fin->setLabel('Fecha de fin de la campaña: ')->setAttributes(array('min' => '2012-01-01', 'max' => '2080-01-01', 'step' => '1')); $this->add($sponsor); $this->add($nombre); $this->add($descripcion); $this->add($slogan); $this->add($fecha_inicio); $this->add($fecha_fin); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Agregar campaña', 'id' => 'submitbutton'))); }
public function editarlocalAction() { $auth = new \Zend\Authentication\AuthenticationService(); if (!$auth->hasIdentity()) { return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/usuario/index/login'); } $id = (int) $this->params()->fromQuery('id', 0); $idrest = (int) $this->params()->fromRoute('in_id', 0); if (!$id) { return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local/index/agregarlocal'); } try { $local = $this->getLocalTable()->getLocal($id); //->toArray(); } catch (\Exception $ex) { return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local'); } $form = new LocalForm(); $servi = $this->getUbigeoTable()->getServicios(); $array = array(); foreach ($servi as $y) { $array[$y['in_id']] = $y['va_nombre']; } $form->get('servicio')->setValueOptions($array); $form->get('pais')->setValue($local['in_idpais']); $hiddenpais = new Element\Hidden('h_pais'); $hiddenpais->setValue($local['in_idpais']); $hiddenpais->setAttribute('id', 'h_pais'); $form->add($hiddenpais); $hiddendepa = new Element\Hidden('h_departamento'); $hiddendepa->setValue($local['in_iddep']); $hiddendepa->setAttribute('id', 'h_departamento'); $form->add($hiddendepa); $hiddenprov = new Element\Hidden('h_provincia'); $hiddenprov->setValue($local['in_idprov']); $hiddenprov->setAttribute('id', 'h_provincia'); $form->add($hiddenprov); $hiddendist = new Element\Hidden('h_distrito'); $hiddendist->setValue($local['in_iddis']); $hiddendist->setAttribute('id', 'h_distrito'); $form->add($hiddendist); $form->bind($local); $form->get('submit')->setAttribute('value', 'MODIFICAR'); $request = $this->getRequest(); //$this->getLocalTable()->editarLocal($id,$data); if ($request->isPost()) { $aux = $this->getRequest()->getPost()->toArray(); $this->getLocalTable()->editarLocal($aux, $id); return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local/index/index/' . $idrest); // $form->setInputFilter($local->getInputFilter()); // $form->setData($request->getPost()); // // $servicio = $this->params()->fromPost('servicio'); // // if ($form->isValid()) { // // $this->getLocalTable()->editarLocal($id,$local);//guardarLocal($local, $servicio); // // return $this->redirect()->toUrl($this-> // getRequest()->getBaseUrl() . '/local/index/index'); // } else { // //$this->getLocalTable()->guardarLocal($local, $servicio); // echo 'no validado'; // exit; // } } return array('id' => $id, 'form' => $form, 'id_re' => $idrest); }
/** * {@inheritDoc} */ public function setValue($value) { return parent::setValue($this->getProxy()->getValue($value)); }
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)); }
function finish() { document.getElementById('pg-percent').style.width = '100%'; document.getElementById('pg-text-1').innerHTML = 'Upload done'; document.getElementById('pg-text-2').innerHTML = 'Upload done'; } </script> </head> <body> <?php $file = new Element\File('file'); $file->setLabel('File'); $progress_key = new Element\Hidden('progress_key'); $progress_key->setAttribute('id', 'progress_key'); $progress_key->setValue(md5(uniqid(rand()))); $submit = new Element\Submit('submit'); $submit->setValue('Upload!'); $form = new Form("ZendForm"); $form->setAttributes(array('enctype' => 'multipart/form-data', 'action' => 'ZendForm.php', 'target' => 'uploadTarget', 'onsubmit' => 'observeProgress();')); $form->prepare(); $formhelper = new Helper\Form(); $formfile = new Helper\FormFile(); $formhidden = new Helper\FormHidden(); $formsubmit = new Helper\FormSubmit(); echo $formhelper->openTag($form); echo $formhidden($progress_key); echo $formfile($file); echo $formsubmit($submit); echo $formhelper->closeTag(); ?>
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)); }
public function ajaxeditAction() { $id = $this->params()->fromRoute('id'); if (!$id) { $this->getResponse()->setStatusCode(404); return; } $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); try { $repository = $entityManager->getRepository($this->getMyEntity()); $article = $repository->find($id); } catch (\Exception $ex) { echo $ex->getMessage(); // this never will be seen fi you don't comment the redirect return $this->redirect()->toRoute('inventory', array('controller' => 'inventory', 'action' => 'index')); } $this->layout()->setVariable('exampleH1', $article->getName()); $form = $this->getForm($article, $entityManager, 'Сохранить'); $hidden = new Element\Hidden('my-mode'); $hidden->setValue('edit'); $form->add($hidden); $form->bind($article); $request = $this->getRequest(); if ($request->isPost()) { $post = $request->getPost(); // uncooment and fix if you want to control the date and time // $post->artcCreated = $post->artcCreatedDate . ' ' . $post->artcCreatedTime; $form->setData($post); if ($form->isValid()) { // $this->prepareData($article); $entityManager->persist($article); $entityManager->flush(); //return $this->redirect()->toRoute('inventory', array('controller' => 'inventory', 'action' => 'index')); } } $viewmodel = new ViewModel(); $request = $this->getRequest(); $viewmodel->setTerminal($request->isXmlHttpRequest()); $is_xmlhttprequest = 1; if (!$request->isXmlHttpRequest()) { $is_xmlhttprequest = 0; } $viewmodel->setVariables(array('form' => $form, 'id' => $id, 'is_xmlhttprequest' => $is_xmlhttprequest, 'mode' => 'edit')); $viewmodel->setTemplate('inventory/basic/ajaxview'); return $viewmodel; }
protected function renderHiddenElement(ElementInterface $element) { $hiddenElement = new Hidden($element->getName()); $hiddenElement->setValue($element->getUnselectedValue()); return $this->getFormHiddenHelper()->__invoke($hiddenElement); }
/** * Load mixed prevalue editor * * @return string */ public function load() { $config = $this->getConfig(); $listDir = $this->getDatatype()->getDatatypesList(); $options = array(); foreach ($listDir as $dir) { $options[$dir] = $dir; } $datatypes = empty($config['datatypes']) ? array() : $config['datatypes']; foreach ($datatypes as $datatypeId => $datatypeConfig) { //Get datatypes $object = $this->loadDatatype($datatypeConfig['name']); //Force configuration $object->getPrevalueEditor()->setConfig(empty($datatypeConfig['config']) ? null : serialize($datatypeConfig['config'])); //Initiliaze prefix $prefix = 'datatypes[' . $datatypeId . ']'; //Create form $fieldset = new Fieldset(); $hidden = new Element\Hidden(); $hidden->setName($prefix . '[name]'); $hidden->setValue($datatypeConfig['name']); $fieldset->add($hidden); $label = new Element\Text(); $label->setName($prefix . '[label]'); $label->setAttribute('class', 'form-control'); $label->setLabel('Label'); $label->setAttribute('id', 'label' . $datatypeId); $label->setValue(empty($datatypeConfig['label']) ? '' : $datatypeConfig['label']); $fieldset->add($label); AbstractForm::addContent($fieldset, $object->getPrevalueEditor()->load(), $prefix); $datatypes[$datatypeId]['fieldset'] = $fieldset; } $data = array(); $data['datatypes'] = $datatypes; $data['modelOptions'] = $options; return $this->addPath(__DIR__)->render('mixed-prevalue.phtml', $data); }
public function __invoke($name, $value, $options = null) { $element = new Hidden($name); $element->setValue($value); return $this->render($element); }
/** * Add tab sub form * * @param mixed $tab \Gc\Tab\Model|array * * @return DocumentType */ public function addTab($tab) { if (!is_array($tab) and !$tab instanceof Tab\Model) { return $this; } $fieldsets = $this->getTabs(); $name = new Element\Text('name'); $description = new Element\Text('description'); $tabId = new Element\Hidden('tab_id'); if ($tab instanceof Tab\Model) { $name->setValue($tab->getName()); $description->setValue($tab->getDescription()); $tabId->setValue($tab->getId()); $tabFieldsetName = $tab->getId(); } else { $name->setValue($tab['name']); $description->setValue($tab['description']); $tabId->setValue(str_replace('tab', '', $tab['id'])); $tabFieldsetName = $tab['id']; } $tabForm = new FieldSet($tabFieldsetName); $fieldsets->add($tabForm); $tabForm->add($name); $tabForm->add($description); $tabForm->add($tabId); //Input filter $this->getInputFilter()->get('tabs')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => true, 'validators' => array(array('name' => 'not_empty')))), $tabFieldsetName); return $this; }
/** * Add widgets * * @param string $fieldsetName Fieldset name * @param array $values Widgets values * * @return void */ public function addWidget($fieldsetName, $values = array()) { $fieldset = new Fieldset($fieldsetName); $this->add($fieldset); $name = new Element\Text('name'); $name->setLabel('Name')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['name']) ? $values['name'] : ''); $fieldset->add($name); $identifier = new Element\Text('identifier'); $identifier->setLabel('Identifier')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['identifier']) ? $values['identifier'] : ''); $fieldset->add($identifier); $radio = new Element\Radio('settings'); $radio->setLabel('Sharing Tool')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setValue(isset($values['settings']) ? $values['settings'] : ''); $radioValues = array(); foreach ($this->getModel()->getDefaultStyles() as $styleName => $style) { $radioValues[$styleName] = array('name' => $style['name'], 'options' => array('img' => isset($style['img']) ? $style['img'] : null)); } $radio->setValueOptions($radioValues); $fieldset->add($radio); $customString = new Element\Textarea('custom_string'); $customString->setLabel('Custom string')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['custom_string']) ? $values['custom_string'] : ''); $fieldset->add($customString); $this->add($fieldset); $chosenList = new Element\Hidden('chosen_list'); $chosenList->setValue(isset($values['chosen_list']) ? $values['chosen_list'] : ''); $fieldset->add($chosenList); $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'settings' => array('name' => 'settings', 'required' => true), 'custom_string' => array('name' => 'custom_string', 'required' => false), 'chosen_list' => array('name' => 'chosen_list', 'required' => false)), $fieldsetName); }
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)); }
/** * Load Image cropper editor * * @return mixed */ public function load() { $parameters = $this->getConfig(); $property = $this->getProperty(); $upload = new Element\File($this->getName()); $upload->setAttribute('class', 'form-control'); $upload->setAttribute('required', $property->isRequired()); $upload->setLabel($property->getName()); $hiddenUpload = new Element\Hidden($this->getName() . '-hidden'); $value = $this->getValue(); if (!empty($value)) { $hiddenUpload->setValue($value); $value = unserialize($value); if (is_array($value)) { foreach ($value as $name => $file) { if ($name == 'original') { continue; } $found = false; foreach ($parameters['size'] as $size) { if ($size['name'] == $name) { $found = true; $file['options'] = $size; break; } } if (empty($found)) { unset($value[$name]); } } } } $this->getHelper('HeadLink')->appendStylesheet('/backend/assets/datatypes/imagecropper/jquery.jcrop.min.css'); $this->getHelper('HeadLink')->appendStylesheet('/backend/assets/datatypes/imagecropper/image-cropper.css'); $this->getHelper('HeadScript')->appendFile('/backend/assets/datatypes/imagecropper/jquery.jcrop.min.js'); return array($upload, $hiddenUpload, $this->addPath(__DIR__)->render('upload-editor.phtml', array('files' => $value, 'id' => $this->getName(), 'options' => $parameters, 'name' => $this->getName()))); }
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)); }
/** * Load mixed editor * * @return string */ public function load() { $config = $this->getConfig(); $values = unserialize($this->getValue()); $datatypes = empty($config['datatypes']) ? array() : $config['datatypes']; $datatypesElements = array(); $lineId = 0; if (!empty($values)) { foreach ($values as $lineId => $datatypeValue) { foreach ($datatypeValue as $datatypeId => $value) { if (empty($datatypes[$datatypeId])) { continue; } $datatypeConfig = $datatypes[$datatypeId]; //Get datatypes $object = $this->loadDatatype($datatypeConfig['name']); $editor = $object->getEditor($this->getProperty()); if (empty($values[$lineId][$datatypeId])) { $values[$lineId][$datatypeId] = array('value' => ''); } $editor->setValue($values[$lineId][$datatypeId]['value']); if (!empty($datatypeConfig['config'])) { $editor->setConfig(serialize($datatypeConfig['config'])); } //Initialize prefix $prefix = $this->getName() . '[' . $lineId . '][' . $datatypeId . ']'; //Create form $fieldset = new Fieldset($datatypeConfig['name'] . $datatypeId); AbstractForm::addContent($fieldset, $editor->load(), $prefix); $datatypesElements[$lineId][$datatypeId]['label'] = empty($datatypeConfig['label']) ? '' : $datatypeConfig['label']; $datatypesElements[$lineId][$datatypeId]['fieldset'] = $fieldset; } } } //Defauts elements $template = array(); foreach ($datatypes as $datatypeId => $datatypeConfig) { $datatypeConfig = $datatypes[$datatypeId]; //Get datatypes $object = $this->loadDatatype($datatypeConfig['name']); $editor = $object->getEditor($this->getProperty()); if (empty($values['#{line}'][$datatypeId])) { $values['#{line}'][$datatypeId] = array('value' => ''); } $editor->setValue($values['#{line}'][$datatypeId]['value']); if (!empty($datatypeConfig['config'])) { $editor->setConfig(serialize($datatypeConfig['config'])); } //Initialize prefix $prefix = $this->getName() . '[#{line}][' . $datatypeId . ']'; //Create form $fieldset = new Fieldset($datatypeConfig['name'] . $datatypeId); $hidden = new Element\Hidden(); $hidden->setName($prefix . '[name]'); $hidden->setValue($datatypeConfig['name']); $fieldset->add($hidden); AbstractForm::addContent($fieldset, $editor->load(), $prefix, '#{line}'); $template[$datatypeId]['label'] = empty($datatypeConfig['label']) ? '' : $datatypeConfig['label']; $template[$datatypeId]['fieldset'] = $fieldset; } $this->getHelper('HeadLink')->appendStylesheet('/backend/assets/datatypes/mixed/mixed.css'); return $this->addPath(__DIR__)->render('mixed-editor.phtml', array('property' => $this->getProperty(), 'datatypes' => $datatypesElements, 'propertyName' => $this->getName(), 'templateElements' => $template)); }
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)); }
/** * Load upload editor * * @return mixed */ public function load() { $parameters = $this->getConfig(); $property = $this->getProperty(); $upload = new Element\File($this->getName()); $value = $this->getValue(); $upload->setLabel($property->getName()); $upload->setAttribute('class', 'form-control')->setAttribute('id', $this->getName()); if (!empty($parameters['is_multiple'])) { $upload->setAttribute('multiple', 'multiple'); $upload->setName($upload->getName()); } $hiddenUpload = new Element\Hidden($this->getName() . '-hidden'); if (!empty($value)) { $hiddenUpload->setValue($value); } return array($upload, $hiddenUpload, $this->addPath(__DIR__)->render('upload-editor.phtml', array('files' => $value, 'id' => $this->getName(), 'isMultiple' => $parameters['is_multiple']))); }
public function __construct(Member $memberEntity, Event $eventEntity, ObjectManager $objectManager) { parent::__construct('entry'); $this->filter = new InputFilter(); $dog = new AppElement\ObjectLiveSearch('dog'); $dog->setOption('object_manager', $objectManager); $dog->setOption('target_class', 'Application\\Entity\\Dog'); $dog->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array('primary' => $memberEntity->getId()), 'orderBy' => array('callName' => 'ASC')))); $dog->setEmptyOption('Select a Dog'); $this->add($dog); $dogFilter = new Input('dog'); $dogFilter->setRequired(true); $this->filter->add($dogFilter); $entryNum = 0; foreach ($eventEntity->getTrials() as $trialEntity) { $trial = new Form('trial_' . $trialEntity->getId()); $trial->setLabel($trialEntity->getDateDisplay()); $this->add($trial); foreach ($trialEntity->getTrialDivisions() as $trialDivisionEntity) { $divisionEntity = $trialDivisionEntity->getDivision(); for ($whichDivisionNum = 1; $whichDivisionNum <= $trialDivisionEntity->getNumOffered(); $whichDivisionNum++) { $entry = new Fieldset('entry_' . $entryNum++); $entry->setOption('twb-layout', 'inline'); $entry->setAttribute('data-price', trim($trialDivisionEntity->getEntryFee(), '$')); $entry->setAttribute('class', 'form-group entry-form'); $this->add($entry); $entry->filter = new InputFilter(); $this->filter->add($entry->filter); $hiddenTrial = new Element\Hidden('trial'); $hiddenTrial->setValue($trialEntity->getId()); $entry->add($hiddenTrial); $hiddenDivision = new Element\Hidden('division'); $hiddenDivision->setValue($divisionEntity->getId()); $entry->add($hiddenDivision); $whichDivision = new Element\Hidden('whichDivision'); $whichDivision->setValue($whichDivisionNum); $entry->add($whichDivision); $entered = new Element\Checkbox('entered'); $entered->setLabel($divisionEntity . ($trialDivisionEntity->getNumOffered() > 1 ? ' #' . $whichDivisionNum : '')); $entry->add($entered); $enteredFilter = new Input('entered'); $enteredFilter->setRequired(false); $entry->filter->add($enteredFilter); if (!$divisionEntity->isAllLevels()) { $level = new AppElement\ObjectLiveSearch('level'); $level->setOption('object_manager', $objectManager); $level->setOption('target_class', 'Application\\Entity\\Level'); $level->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('rank' => 'ASC')))); $level->setEmptyOption('Select a Level'); $entry->add($level); $levelFilter = new Input('level'); $levelFilter->setRequired(false); $entry->filter->add($levelFilter); } $exhibitionOnly = new Element\Checkbox('exhibitionOnly'); $exhibitionOnly->setLabelAttributes(array('class' => 'small col-md-offset-2')); $exhibitionOnly->setLabel('For exhibition only'); $entry->add($exhibitionOnly); $exhibitionOnlyFilter = new Input('exhibitionOnly'); $exhibitionOnlyFilter->setRequired(false); $entry->filter->add($exhibitionOnlyFilter); } } } $buttons = new Form('buttons'); $buttons->setOption('twb-layout', 'inline'); $buttons->setAttribute('class', 'form-group'); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-event pull-right'); $submit->setOption('glyphicon', 'circle-arrow-up'); $submit->setLabel('Submit Entry'); $buttons->add($submit); $cancel = new Element\Submit('cancel'); $cancel->setAttribute('formnovalidate', true); $cancel->setAttribute('class', 'btn-warning pull-right'); $cancel->setOption('glyphicon', 'ban-circle'); $cancel->setLabel('Cancel'); $buttons->add($cancel); $this->add($buttons); }
public function posterlabAction() { $id = (int) $this->params()->fromRoute("id", 0); $menu = $this->getContenutiDao()->relatorePerId($id); $menuArray = $this->getContenutiDao()->defaultPerId($id); $ids = (int) $this->params()->fromQuery("ids"); if (!$ids) { $ids = $menuArray->getId(); } $this->initAjaxContext(); $inizio = $this->getSessioniDao()->BuscoId($id)->getInizio(); $timer = $this->getPosterlabsDao()->tuttiPerId($id)->getDurata(); $generaloposter = $this->getPosterlabsDao()->tuttiPerId($id); $timerdate = new DateTime($inizio); $timerdate->modify('+' . $timer . ' minutes'); $tiempo = $timerdate->format('Y-m-d H:i:s'); //print_r($tiempo);die; $nombre = $generaloposter->getRelatori()->getNome(); $apellido = $generaloposter->getRelatori()->getCognome(); $relator = $nombre . ' ' . $apellido; $verifica = $this->getContenutiDao()->buscaId($ids); $passwordPosterlab = $generaloposter->getPassword2(); $layout = $this->layout(); // asignamos algunas variables al layout $layout->timeraggio = $tiempo; $layout->password = $passwordPosterlab; $seccionactiva = $this->getSessioniDao()->BuscoId($id)->getStato(); $seccionactual = $this->getSessioniDao()->BuscoId($id)->getId(); //controllo sessione attiva if ($seccionactiva == 0) { return $this->redirect()->toRoute('application', array('controller' => 'index', 'action' => 'index')); } //id seccion activa $idseccion = $this->getSessioniDao()->BuscoId($id)->getId(); //verifico domanda if ($verifica->getTipo() == 1) { $postit = $this->getInterattivoDao()->posiciones($id, $seccionactual); $busco_ultimo = $this->getInterattivoDao()->posiciones($id, $seccionactual)->toArray(); $contador_postit = count($busco_ultimo); if ($contador_postit > 0) { $todo_id = array(); foreach ($busco_ultimo as $key) { $todo_id[] = $key['id']; } $ultimo = max($todo_id); } $color = 'yellow'; $patron = 'Y-m-d H:i:s'; $fecha = new DateTime(); $form = new Nascosto("Nascosto"); $form->get('id')->setValue($ids); $form->get('posterlab')->setValue($id); $form->get('tipo')->setValue(1); $form->get('data')->setValue($fecha->format($patron)); $form->get('color')->setValue('yellow'); $form->get('xyz')->setValue('0x101x100'); $form->get('nome')->setValue($relator); $form->get('sessione')->setValue($idseccion); $form->get('stato')->setValue(1); $hidden = new Element\Hidden('lasted'); $hidden->setAttributes(array('class' => 'lasted')); if ($contador_postit > 0) { $hidden->setValue($ultimo); } else { $hidden->setValue(0); } $form->add($hidden); if ($ids !== 0) { $contenuto = $this->getContenutiDao()->buscaId($ids); $imagen = $contenuto->getBackground(); } else { $contenuto = $this->getContenutiDao()->defaultPerId($id); $imagen = $contenuto->getBackground(); } //print_r($contenuto);die; if (null === $menu) { return $this->redirect()->toRoute('application', array('controller' => 'index', 'action' => 'index')); } return new ViewModel(array('form' => $form, 'posterlab' => $menu, 'contenuto' => $contenuto, 'imagen' => $imagen, 'ids' => $ids, 'postit' => $postit, 'timeraggio' => $tiempo, 'cantidad' => $contador_postit, 'color' => $color, 'password' => $passwordPosterlab)); } //verifico risposta if ($verifica->getTipo() == 2) { $postit = $this->getInterattivoDao()->posiciones2($id, $seccionactual); $busco_ultimo = $this->getInterattivoDao()->posiciones2($id, $seccionactual)->toArray(); //print_r($busco_ultimo);die; $contador_postit = count($busco_ultimo); if ($contador_postit > 0) { $todo_id = array(); foreach ($busco_ultimo as $key) { $todo_id[] = $key['id']; } $ultimo = max($todo_id); } $color = 'blue'; $patron = 'Y-m-d H:i'; $fecha = new DateTime(); $form = new Nascosto("Nascosto"); $form->get('id')->setValue($ids); $form->get('posterlab')->setValue($id); $form->get('tipo')->setValue(2); $form->get('data')->setValue($fecha->format($patron)); $form->get('color')->setValue('blue'); $form->get('xyz')->setValue('0x101x100'); $form->get('nome')->setValue($relator); $form->get('sessione')->setValue($idseccion); $form->get('stato')->setValue(1); $hidden = new Element\Hidden('lasted'); $hidden->setValue(1); $form->add($hidden); $hidden = new Element\Hidden('lasted'); $hidden->setAttributes(array('class' => 'lasted')); if ($contador_postit > 0) { $hidden->setValue($ultimo); } else { $hidden->setValue(0); } $form->add($hidden); if ($ids !== 0) { $contenuto = $this->getContenutiDao()->buscaId($ids); $imagen = $contenuto->getBackground(); } else { $contenuto = $this->getContenutiDao()->defaultPerId($id); $imagen = $contenuto->getBackground(); } if (null === $menu) { return $this->redirect()->toRoute('application', array('controller' => 'index', 'action' => 'index')); } return new ViewModel(array('form' => $form, 'posterlab' => $menu, 'contenuto' => $contenuto, 'imagen' => $imagen, 'ids' => $ids, 'postit' => $postit, 'timeraggio' => $tiempo, 'cantidad' => $contador_postit, 'color' => $color, 'password' => $passwordPosterlab)); } //verifico contenuto if ($verifica->getTipo() == 3) { if ($ids !== 0) { $contenuto = $this->getContenutiDao()->buscaId($ids); $imagen = $contenuto->getBackground(); } else { $contenuto = $this->getContenutiDao()->defaultPerId($id); $imagen = $contenuto->getBackground(); } if (null === $menu) { return $this->redirect()->toRoute('application', array('controller' => 'index', 'action' => 'index')); } return new ViewModel(array('posterlab' => $menu, 'contenuto' => $contenuto, 'imagen' => $imagen, 'ids' => $ids, 'timeraggio' => $tiempo, 'password' => $passwordPosterlab)); } }
public function __construct(OrmNivel $orm = null) { parent::__construct("formNivel"); /* * txtId */ $txtId = new Element\Hidden("id"); $txtNome = new Element\Text("nome"); $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome da Categoria', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true')); /* * chkDashbord */ $chkDashbord = new Element\Checkbox('dashboard'); $chkDashbord->setAttributes(array('id' => "switch01", 'class' => 'onoffswitch-checkbox')); $chkPublicador = new Element\Checkbox('publicador'); $chkPublicador->setAttributes(array('id' => "switch02", 'class' => 'onoffswitch-checkbox')); /* * chkCongregacao */ $chkCongregacao = new Element\Checkbox('congregacao'); $chkCongregacao->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox')); /* * chkRelatorio */ $chkRelatorio = new Element\Checkbox('relatorio'); $chkRelatorio->setAttributes(array('id' => "switch03", 'class' => 'onoffswitch-checkbox')); /* * chkGrupo */ $chkGrupo = new Element\Checkbox('grupo'); $chkGrupo->setAttributes(array('id' => "switch04", 'class' => 'onoffswitch-checkbox')); /* * chkUsuario */ $chkUsuario = new Element\Checkbox('usuario'); $chkUsuario->setAttributes(array('id' => "switch05", 'class' => 'onoffswitch-checkbox')); /* * chkNivel */ $chkNivel = new Element\Checkbox('nivel'); $chkNivel->setAttributes(array('id' => "switch06", 'class' => 'onoffswitch-checkbox')); /* * chkPrivilegios */ $chkPrivilegios = new Element\Checkbox('privilegios'); $chkPrivilegios->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox')); /* * chkEscolaMinisterio */ $chkEscolaMinisterio = new Element\Checkbox('escola'); $chkEscolaMinisterio->setAttributes(array('id' => "switch08", 'class' => 'onoffswitch-checkbox')); /* * 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 Objetos */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtNome->setValue($orm->getNome()); $chkDashbord->setValue($orm->getDashboard()); $chkPublicador->setValue($orm->getPublicador()); $chkGrupo->setValue($orm->getGrupo()); $chkCongregacao->setValue($orm->getCongregacao()); $chkRelatorio->setValue($orm->getRelatorio()); $chkUsuario->setValue($orm->getUsuario()); $chkPrivilegios->setValue($orm->getPrivilegios()); $chkEscolaMinisterio->setValue($orm->getEscolaMinisterio()); $chkNivel->setValue($orm->getNivel()); } /* * Adiciona Objetos ao form */ $this->add($txtId); $this->add($txtNome); $this->add($chkDashbord); $this->add($chkPublicador); $this->add($chkGrupo); $this->add($chkRelatorio); $this->add($chkCongregacao); $this->add($chkUsuario); $this->add($chkNivel); $this->add($chkPrivilegios); $this->add($chkEscolaMinisterio); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); /* * Form */ $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }