public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report4Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_PLAN_YEAR');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', false);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 4));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_REPORTPLANKIND');
     $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     if (@(!$this->params['establishment'])) {
         $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
         $form->addElement($e);
     }
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
Exemple #3
0
 /**
  * @group ZF-7552
  */
 public function testAddDecoratorsKeepsNonNumericKeyNames()
 {
     $this->form->addDecorators(array(array(array('td' => 'HtmlTag'), array('tag' => 'td')), array(array('tr' => 'HtmlTag'), array('tag' => 'tr')), array('HtmlTag', array('tag' => 'baz'))));
     $t1 = $this->form->getDecorators();
     $this->form->setDecorators($t1);
     $t2 = $this->form->getDecorators();
     $this->assertEquals($t1, $t2);
 }
Exemple #4
0
 /**
  * @group ZF-3597
  */
 public function testSettingElementDecoratorsWithConcreteDecoratorShouldHonorOrder()
 {
     $this->form->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form'));
     $this->form->addElementPrefixPath('My_Decorator', dirname(__FILE__) . '/_files/decorators/', 'decorator');
     $this->form->addElement('text', 'test', array('label' => 'Foo', 'description' => 'sample description'));
     require_once dirname(__FILE__) . '/_files/decorators/TableRow.php';
     $decorator = new My_Decorator_TableRow();
     $this->form->setElementDecorators(array('ViewHelper', $decorator));
     $html = $this->form->render($this->getView());
     $this->assertRegexp('#<tr><td>Foo</td><td>.*?<input[^>]+>.*?</td><td>sample description</td></tr>#s', $html, $html);
 }
Exemple #5
0
 /**
  * Set Form defaults
  * - disable default decorators
  * - set form & displaygroup decorators
  * - set needed prefix path for bootstrap decorators
  * - set form element decorators
  *
  * @param Zend_Form $form The form instance.
  * @param string $format Standard, minimal, table.
  *
  * @return void
  */
 protected static function setFormDefaults(Zend_Form $form, $format)
 {
     $form->setDisableLoadDefaultDecorators(true);
     $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
     $form->setDecorators(self::$_FormDecorator[$format]);
     if (self::BOOTSTRAP == $format || self::BOOTSTRAP_MINIMAL == $format) {
         $form->addElementPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
         $form->addPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
     }
     $form->setElementDecorators(self::$_ElementDecorator[$format]);
     return;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod(Zend_Form::METHOD_POST);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml'))));
     $items = $this->getGuideYears();
     $e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items)));
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 public function getInfoForm()
 {
     $form = new Zend_Form();
     $form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/infoForm10.phtml'), 'Form')));
     $e = new Zend_Form_Element_Hidden('step', array('value' => 2));
     $form->addElement($e);
     $e = new Zend_Form_Element_Hidden('filename');
     $form->addElement($e);
     $e = new Zend_Form_Element_Hidden('validreports');
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('submit', array('label' => 'Далі'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper'));
     return $form;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report9Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 9));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 public static function getForm()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $form = new Zend_Form();
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'editor/changesForm.phtml'))));
     $zdate = new Zend_Date();
     $e = new Zend_Dojo_Form_Element_DateTextBox('fromDate', array('label' => 'From', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     $e = new Zend_Dojo_Form_Element_DateTextBox('toDate', array('label' => 'To', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     //		$e = new Zend_Dojo_Form_Element_Button( 'refresh', array ('label' => 'Refresh' ) );
     //		$e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     //		$form->addElement($e);
     Zend_Dojo::enableForm($form);
     $form->setDefaults(array('toDate' => $zdate->getIso(), 'fromDate' => $zdate->getIso()));
     return $form;
 }
 public static function getUploadForm()
 {
     $form = new Zend_Form();
     $form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/uploadForm.phtml')), 'Errors'));
     $f = new Zend_Form_Element_File('file');
     //, array ('label' => 'Веберіть файл пакету') );
     //		$f->setAttrib ( 'style', 'width: 600px' );
     $f->setRequired();
     $f->addValidator('Count', false, 1);
     //		$f->addValidator ( 'Size', false, 204800 );
     $f->addValidator('Extension', false, 'xls');
     $cfg = Zend_Registry::get('cfg');
     $target = $cfg['temp']['path'] . Zend_Auth::getInstance()->getIdentity()->NODEID . '.xls';
     $f->addFilter('Rename', array('target' => $target, 'overwrite' => 'true'));
     $form->addElement($f);
     $e = new Zend_Form_Element_Submit('submit', array('label' => 'Завантажити'));
     $form->addElement($e);
     return $form;
 }
Exemple #11
0
 public static function build($formConfig)
 {
     $decorators = array();
     if ($formConfig->useInternalError) {
         $decorators[] = new Saf_Form_Zend_Helper_Error(array('class' => 'formErrors', 'id' => $newFormId . 'Errors', 'placement' => 'append', 'escape' => false));
     }
     $newForm = new Zend_Form();
     $newForm->setConfig($formConfig);
     $newForm->removeDecorator('HtmlTag');
     $newFormId = $newForm->getId();
     $formDecorator = $newForm->getDecorator('Form');
     $elementDecorator = $newForm->getDecorator('FormElements');
     $decorators[] = $elementDecorator;
     $decorators[] = $formDecorator;
     $newForm->setDecorators($decorators);
     foreach ($newForm->getElements() as $element) {
         self::fixElement($element);
     }
     return $newForm;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report8Form.phtml'))));
     $items = $this->getPeriodItems('REQ_EDUSTAT_FAIL');
     $e = new Zend_Form_Element_Select('period', array('label' => 'На дату', 'multiOptions' => $items, 'required' => true));
     $form->addElement($e);
     $items = $this->getGuideItems('T_DEPARTMENT', true);
     $e = new Zend_Form_Element_Select('department', array('label' => 'Факультет', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 8));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report1Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true));
     $form->addElement($e);
     $items = $this->getGuideItems('T_STRUCTURE_ITEM', true, false, 'CT.TITLE');
     $e = new Zend_Form_Element_Select('establishment', array('label' => 'Установа', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', true);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', true);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRY', true);
     $e = new Zend_Form_Element_Select('country', array('label' => 'Громадянство (країна)', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDULEVEL');
     $e = new Zend_Form_Element_MultiCheckbox('edulevel', array('label' => 'Рівень підготовки', 'multiOptions' => $items));
     $e->setValue(array_keys($items));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 1));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     $auth = Zend_Auth::getInstance();
     $ident = $auth->getIdentity();
     if ($ident->STRUCTURE_CODE != 0) {
         $form->getElement('establishment')->setValue($ident->STRUCTUREID);
     }
     return $form;
 }
Exemple #14
0
 /**
  * @param unknown_type $formName
  * @param unknown_type $options
  * @throws Exception
  * @return Zend_Form
  */
 public function getForm($formName, $options = null, $useTemplate = false)
 {
     if (is_null(self::$_forms)) {
         if (is_file(APPLICATION_PATH . '/configs/forms.ini')) {
             $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini');
         } else {
             $config = new Zend_Config(include_once APPLICATION_PATH . '/configs/forms.php');
         }
         $config = $config->toArray();
         self::$_forms = $config;
     }
     if (!array_key_exists($formName, $config)) {
         throw new Exception("Form not exist");
     }
     if ($useTemplate) {
         //$form = new Zend_Form_Template($config[$formName]);
         //$form->setTemplate($formName, $options);
         $form = new Zend_Form($config[$formName]);
         $elements = $form->getElements();
         foreach ($elements as &$element) {
             $element->removeDecorator('Label');
             $element->removeDecorator('HtmlTag');
             $element->removeDecorator('DtDdWrapper');
             $element->removeDecorator('Description');
             $element->removeDecorator('Errors');
             $element->addDecorator(array('data' => 'Errors'), array('tag' => 'p', 'class' => 'description'));
         }
         $filter = new Zend_Filter_Word_CamelCaseToDash();
         $formName = $filter->filter($formName);
         $options['viewScript'] = 'forms/' . $formName . '.phtml';
         $form->setDecorators(array(array('viewScript', $options)));
     } else {
         $form = new Zend_Form($config[$formName]);
         /*  $form->addElementPrefixPath('Zend_Decorator',
             'Zend/Decorator/',
             'decorator');
             $form->setDecorators(array('Default'));*/
         //Zend_Debug::dump($form->getDecorator('Errors'));
         /*$elements = $form->getElements();
                     foreach ($elements as &$element) {
         
                         $element->setDecorators(
                             array(
                             'ViewHelper',
                             'Errors',
                             array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element')),
                             'Label',
                             array(array('row' => 'HtmlTag'), array('tag' => 'li'))
                             )
                         );
         
                         //Zend_Debug::dump($element->getDecorator('Errors'));
         
                     };*/
         /*
                     $form->setElementDecorators(array(
                         'ViewHelper',
                         array('Errors', array('class' => 'help-inline control-error')),
                         array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'controls')),
                         array(array('label' => 'Label'), array('class' => 'control-label')),
                         array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'control-group')),
                     ));
         */
         // $form->addElement("text", "naem", $opt);
         /* $form->setDecorators(array(
                'FormElements',
                array('Form', array('class' => 'form-horizontal'))
            ));*/
         //Zend_Debug::dump($form);
         // вынести декораторы
     }
     $formAction = $form->getAction();
     $routes = $this->getRouterNames();
     $actionParams = array();
     if (is_array($options) && array_key_exists('actionParams', $options)) {
         $actionParams = $options['actionParams'];
     }
     if (in_array($formAction, $routes)) {
         if (array_key_exists("actionParams", $config[$formName]) && is_array($config[$formName]['actionParams'])) {
             $actionParams = $config[$formName]['actionParams'];
         }
         $form->setAction($this->_url($actionParams, $formAction));
     }
     //Zend_Debug::dump($form);
     return $form;
 }
$autoloader = Zend_Loader_Autoloader::getInstance();
$form = new Zend_Form();
// Set form name, id, method and action
$form->setName('fileUpload')->setAttrib('id', 'fileUpload')->setMethod('post')->setAttrib('enctype', 'multipart/form-data')->setAction('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$file = new Zend_Form_Element_File('file');
$file->setLabel('File')->setRequired(true)->setValueDisabled(False)->addValidator('Extension', FALSE, 'jpg,jpeg')->addValidator('Size', false, array('min' => 20, 'max' => 20000000));
$file->getValidator('Extension')->setMessage('JPEGs only');
// Create text area for message
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message');
// Create a submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit')->setAttrib('id', 'submit');
// Set the ViewScript decorator for the form and tell it which
// template file to use
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php'))));
// Add the form elements AFTER the viewscript decorator has been set
$form->addElements(array($file, $message, $submit));
// Get rid of all element decorators except for ViewHelper to render
// the individual elements and Errors decorator to render the errors.
$form->setElementDecorators(array('ViewHelper', 'Errors'));
// The file element requires the File decorator instead of the
// ViewHelper decorator
$file->setDecorators(array('File', 'Errors'));
// Create an instance of Zend_View and set the directory
// for the template files
$view = new Zend_View();
$view->setScriptPath(__DIR__);
// Tell all the elements in the form which view to use when rendering
foreach ($form as $item) {
    $item->setView($view);
 public function indexAction()
 {
     // action body
     $idEncuesta = $this->getParam("idEncuesta");
     $encuesta = $this->encuestaDAO->obtenerEncuesta($idEncuesta);
     $secciones = $this->seccionDAO->obtenerSecciones($idEncuesta);
     $formulario = new Zend_Form($encuesta->getHash());
     //debemos agregar a este formulario campos para identificar quien es el que esta llenando esta encuesta
     $eSubCabecera = new Zend_Form_SubForm();
     $eSubCabecera->setLegend("Datos Personales: ");
     $eEncuesta = new Zend_Form_Element_Hidden("idEncuesta");
     $eEncuesta->setValue($idEncuesta);
     $eReferencia = new Zend_Form_Element_Text("referencia");
     $eReferencia->setLabel("Boleta o Clave : ");
     $eReferencia->setAttrib("class", "form-control");
     $eReferencia->setDecorators($this->decoratorsPregunta);
     $eSubCabecera->addElements(array($eEncuesta, $eReferencia));
     $eSubCabecera->setDecorators($this->decoratorsSeccion);
     $formulario->addSubForm($eSubCabecera, "referencia");
     //============================================= Iteramos a traves de las secciones del grupo
     foreach ($secciones as $seccion) {
         //============================================= Cada seccion es una subforma
         $subFormSeccion = new Zend_Form_SubForm($seccion->getHash());
         $subFormSeccion->setLegend("Sección: " . $seccion->getNombre());
         //============================================= Obtenemos los elemntos de la seccion
         $elementos = $this->seccionDAO->obtenerElementos($seccion->getIdSeccion());
         foreach ($elementos as $elemento) {
             //============================================= Verificamos que tipo de elemento es
             if ($elemento instanceof Encuesta_Model_Pregunta) {
                 //============================================= Aqui ya la agregamos a la seccion
                 $this->agregarPregunta($subFormSeccion, $elemento);
             } elseif ($elemento instanceof Encuesta_Model_Grupo) {
                 //============================================= un grupo es otra subform
                 $subFormGrupo = new Zend_Form_SubForm($elemento->getHash());
                 $subFormGrupo->setLegend("Grupo: " . $elemento->getNombre());
                 $preguntasGrupo = $this->grupoDAO->obtenerPreguntas($elemento->getIdGrupo());
                 foreach ($preguntasGrupo as $pregunta) {
                     //============================================= Aqui ya la agregamos al grupo
                     $this->agregarPregunta($subFormGrupo, $pregunta);
                 }
                 $subFormGrupo->setDecorators($this->decoratorsGrupo);
                 $subFormSeccion->addSubForm($subFormGrupo, $elemento->getIdGrupo());
             }
         }
         $subFormSeccion->setDecorators($this->decoratorsSeccion);
         $formulario->addSubForm($subFormSeccion, $seccion->getIdSeccion());
     }
     $eSubmit = new Zend_Form_Element_Submit("submit");
     $eSubmit->setLabel("Enviar Encuesta");
     $eSubmit->setAttrib("class", "btn btn-success");
     $formulario->addElement($eSubmit);
     $formulario->setDecorators($this->formDecorators);
     $this->view->encuesta = $encuesta;
     $this->view->formulario = $formulario;
 }
Exemple #17
0
 /**
  * Apply this element to the form as the output decorator.
  *
  * @param \Zend_Form $form
  * @param mixed $width The style.width content for the labels
  * @param array $order The display order of the elements
  * @param string $errorClass Class name to display all errors in
  * @return \MUtil_Html_DlElement
  */
 public function setAsFormLayout(\Zend_Form $form, $width = null, $order = array('label', 'element', 'description'), $errorClass = 'errors')
 {
     $this->_repeatTags = true;
     $prependErrors = $errorClass;
     // Make a Lazy repeater for the form elements and set it as the element repeater
     $formrep = new \MUtil_Lazy_RepeatableFormElements($form);
     $formrep->setSplitHidden(true);
     // These are treated separately
     $this->setRepeater($formrep);
     if (null === $width) {
         $attr = array();
     } else {
         $attr['style'] = array('display' => 'inline-block', 'width' => $width);
     }
     // Place the choosen renderers
     foreach ($order as $renderer) {
         switch ($renderer) {
             case 'label':
                 $this->label($formrep->element, $attr);
                 // Set label with optional width
                 break;
             case 'error':
                 $prependErrors = false;
                 // Intentional fall through
             // Intentional fall through
             default:
                 $this->append($formrep->{$renderer});
         }
     }
     // Set this element as the form decorator
     $decorator = new \MUtil_Html_ElementDecorator();
     $decorator->setHtmlElement($this);
     $decorator->setPrologue($formrep);
     // Renders hidden elements before this element
     if ($prependErrors) {
         $decorator->setPrependErrors(\MUtil_Html_ListElement::ul(array('class' => $errorClass, 'style' => array('margin-left' => $width))));
     }
     $form->setDecorators(array($decorator, 'AutoFocus', 'Form'));
     return $this;
 }
Exemple #18
0
 /**
  * Apply this element to the form as the output decorator.
  *
  * @param \Zend_Form $form
  * @param mixed $width The style.width content for the labels
  * @param array $order The display order of the elements
  * @return \MUtil_Html_DlElement
  */
 public function setAsFormLayout(\Zend_Form $form, $width = null, array $order = array('element', 'errors', 'description'))
 {
     // Make a Lazy repeater for the form elements and set it as the element repeater
     $formrep = new \MUtil_Lazy_RepeatableFormElements($form);
     $formrep->setSplitHidden(true);
     // These are treated separately
     $this->setRepeater($formrep);
     if (null === $width) {
         $attr = array();
     } else {
         $attr['style'] = array('width' => $width);
     }
     $this->dt()->label($formrep->element, $attr);
     // Set label dt with optional width
     $dd = $this->dd();
     foreach ($order as $renderer) {
         $dd[] = $formrep->{$renderer};
     }
     // $this->dd($formrep->element, ' ', $formrep->errors, ' ', $formrep->description);
     // $this->dd($formrep->element, $formrep->description, $formrep->errors);
     // Set this element as the form decorator
     $decorator = new \MUtil_Html_ElementDecorator();
     $decorator->setHtmlElement($this);
     $decorator->setPrologue($formrep);
     // Renders hidden elements before this element
     $form->setDecorators(array($decorator, 'AutoFocus', 'Form'));
     return $this;
 }
 public function addInterfaceCheckbox($value)
 {
     $form = new Zend_Form();
     $checkbox_element = new Zend_Form_Element_Checkbox("checktoogleInterface");
     $checkbox_element->setValue($value);
     $checkbox_element->setAttrib("id", "checktoogleInterface");
     $form->addElement($checkbox_element);
     $form->setElementDecorators(array('ViewHelper'));
     $form->setDecorators(array('FormElements', 'Form'));
     $this->view->interfacingcheckbox = $form;
 }
Exemple #20
0
 /**
  * Set the form decorators by the given string format or by the default div style
  *
  * @param object $objForm        Zend_Form pointer-reference
  * @param string $constFormat    Project_Plugin_FormDecoratorDefinition constants
  * @return NULL
  */
 public static function setFormDecorator(Zend_Form $form, $format = self::BOOTSTRAP, $submit_str = 'submit', $cancel_str = 'cancel')
 {
     /**
      * - disable default decorators
      * - set form & displaygroup decorators
      */
     $form->setDisableLoadDefaultDecorators(true);
     $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
     $form->setDecorators(self::$_FormDecorator[$format]);
     // set needed prefix path for bootstrap decorators
     if ($format == self::BOOTSTRAP) {
         $form->addElementPrefixPath('EasyBib_Form_Decorator', 'EasyBib/Form/Decorator', Zend_Form::DECORATOR);
     }
     // set form element decorators
     $form->setElementDecorators(self::$_ElementDecorator[$format]);
     // set submit button decorators
     if ($form->getElement($submit_str)) {
         $form->getElement($submit_str)->setDecorators(self::$_SubmitDecorator[$format]);
         if ($format == self::BOOTSTRAP) {
             $attribs = $form->getElement($submit_str)->getAttrib('class');
             if (empty($attribs)) {
                 $attribs = array('btn', 'primary');
             } else {
                 if (is_string($attribs)) {
                     $attribs = array($attribs);
                 }
                 $attribs = array_unique(array_merge(array('btn'), $attribs));
             }
             $form->getElement($submit_str)->setAttrib('class', $attribs)->setAttrib('type', 'submit');
             if ($form->getElement($cancel_str)) {
                 $form->getElement($submit_str)->getDecorator('HtmlTag')->setOption('openOnly', true);
             }
         }
     }
     // set cancel button decorators
     if ($form->getElement($cancel_str)) {
         $form->getElement($cancel_str)->setDecorators(self::$_ResetDecorator[$format]);
         if ($format == self::BOOTSTRAP) {
             $attribs = $form->getElement($cancel_str)->getAttrib('class');
             if (empty($attribs)) {
                 $attribs = array('btn');
             } else {
                 if (is_string($attribs)) {
                     $attribs = array($attribs);
                 }
                 $attribs = array_unique(array_merge(array('btn'), $attribs));
             }
             $form->getElement($cancel_str)->setAttrib('class', $attribs)->setAttrib('type', 'reset');
             if ($form->getElement($submit_str)) {
                 $form->getElement($cancel_str)->getDecorator('HtmlTag')->setOption('closeOnly', true);
             }
         }
     }
     // set hidden input decorators
     foreach ($form->getElements() as $e) {
         if ($e->getType() == 'Zend_Form_Element_Hidden') {
             $e->setDecorators(self::$_HiddenDecorator[$format]);
         }
     }
 }