Ejemplo n.º 1
1
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('menu')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Menu Item Information');
     $subForm1->setDescription('Menu Item Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $title = new Zend_Form_Element_Text('title', array('class' => 'required', 'maxlength' => 200));
     $title->setRequired(true)->setLabel('Title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $link = new Zend_Form_Element_Text('link', array('maxlength' => 200));
     $link->setLabel('Link')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDescription('Use module/controller/action for internal links or http://www.example.com for external links');
     $open_window = new Zend_Form_Element_Select('open_window', array('class' => 'required', 'maxlength' => 200));
     $open_window->setRequired(true)->setLabel('Open Window')->setMultiOptions(Fox::getModel('navigation/menu')->getAllTargetWindows());
     $status = new Zend_Form_Element_Select('status', array('class' => 'required', 'maxlength' => 200));
     $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('navigation/menu')->getAllStatuses());
     $sort_order = new Zend_Form_Element_Text('sort_order', array('class' => 'required', 'maxlength' => 200));
     $sort_order->setRequired(true)->setLabel('Sort Order')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $style_class = new Zend_Form_Element_Text('style_class');
     $style_class->setLabel('Style Class')->addFilter('StripTags')->addFilter('StringTrim');
     $menugroup = new Zend_Form_Element_Multiselect('menu_group', array('class' => 'required'));
     $menugroup->setRequired(true)->setLabel('Menu Group')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setMultiOptions(Fox::getModel('navigation/menugroup')->getMenuGroupOptions());
     $subForm1->addElements(array($idField, $title, $link, $open_window, $sort_order, $style_class, $status, $menugroup));
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 2
0
 public function buildFromArray(array $array)
 {
     $translator = $this->getTranslator();
     foreach ($array as $language => $data) {
         $languageForm = new Zend_Form_SubForm();
         $languageForm->setLegend($translator->translate("setup_language_{$language}"));
         $this->addSubForm($languageForm, $language);
         foreach ($data as $key => $values) {
             switch ($key) {
                 case 'file':
                     $fileForm = new Zend_Form_SubForm();
                     $languageForm->addSubForm($fileForm, 'file');
                     $fileForm->addElement('hidden', 'filename');
                     $fileForm->addElement('textarea', 'contents', array('label' => $translator->translate('setup_page_content')));
                     break;
                 case 'key':
                     $keyForm = new Zend_Form_SubForm();
                     $languageForm->addSubForm($keyForm, 'key');
                     $translationUnits = array_keys($values);
                     foreach ($translationUnits as $translationUnit) {
                         $keyForm->addElement('text', $translationUnit, array('label' => $translator->translate("setup_{$translationUnit}"), 'size' => 90));
                     }
                     break;
             }
         }
     }
     return $this;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public function init()
 {
     /* Form Elements & Other Definitions Here ... */
     $subForm = new Zend_Form_SubForm();
     $subForm->setLegend("Alta de Municipio");
     $eMunicipio = new Zend_Form_Element_Text('municipio');
     $eMunicipio->setLabel('Municipio:');
     $eMunicipio->setAttrib("class", "form-control");
     $eAgregar = new Zend_Form_Element_Submit('agregar');
     $eAgregar->setLabel('Agregar');
     $eAgregar->setAttrib("class", "btn btn-primary");
     $subForm->addElements(array($eMunicipio, $eAgregar));
     $this->addElements(array($eMunicipio, $eAgregar));
 }
 protected function addItemXpathsToExtend($itemXpathsToExtend)
 {
     if (count($itemXpathsToExtend) == 0) {
         $itemXpathsToExtend = array(new Kaltura_Client_Type_ExtendingItemMrssParameter());
     }
     $mainSubForm = new Zend_Form_SubForm();
     $mainSubForm->setLegend('Item XPaths To Extend');
     $mainSubForm->setDecorators(array('FormElements', array('ViewScript', array('viewScript' => 'distribution-item-xpath-to-extend.phtml', 'placement' => 'APPEND')), 'Fieldset'));
     $i = 1;
     $extendCategory = false;
     $extendParentCategory = false;
     foreach ($itemXpathsToExtend as $itemXPath) {
         /* @var $itemXPath Kaltura_Client_Type_ExtendingItemMrssParameter */
         //if it a category identifier
         if ($itemXPath->identifier instanceof Kaltura_Client_Type_CategoryIdentifier) {
             /* @var $identifier Kaltura_Client_Type_CategoryIdentifier */
             $identifier = $itemXPath->identifier;
             //if the parameters are set exactly as the admin console sets.
             if ($itemXPath->xpath == '//category' && $itemXPath->extensionMode == Kaltura_Client_Enum_MrssExtensionMode::REPLACE && $identifier->identifier == Kaltura_Client_Enum_CategoryIdentifierField::FULL_NAME) {
                 foreach (explode(',', $identifier->extendedFeatures) as $extendedFeature) {
                     if ($extendedFeature == Kaltura_Client_Enum_ObjectFeatureType::METADATA) {
                         $extendCategory = true;
                     } elseif ($extendedFeature == Kaltura_Client_Enum_ObjectFeatureType::ANCESTOR_RECURSIVE) {
                         $extendParentCategory = true;
                     }
                 }
             }
             continue;
         }
         $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true));
         $subForm->setDecorators(array('FormElements'));
         $subForm->addElement('text', 'itemXpathsToExtend', array('decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'div'))), 'isArray' => true, 'value' => $itemXPath->xpath));
         $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++);
     }
     //set the extend category metadata checkbox
     $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true));
     $subForm->setDecorators(array('FormElements'));
     $subForm->addElement('checkbox', 'includeCategoryInMrss', array('label' => 'Include category-level custom metadata in MRSS', 'isArray' => true, 'value' => $extendCategory));
     $subForm->getElement('includeCategoryInMrss')->getDecorator('Label')->setOption('placement', 'APPEND');
     $subForm->getElement('includeCategoryInMrss')->setChecked($extendCategory);
     $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++, 99);
     //set the extend category parent metadata checkbox
     $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true));
     $subForm->setDecorators(array('FormElements'));
     $subForm->addElement('checkbox', 'includeCategoryParentInMrss', array('label' => 'Include parent categories', 'isArray' => true, 'value' => $extendParentCategory));
     $subForm->getElement('includeCategoryParentInMrss')->getDecorator('Label')->setOption('placement', 'APPEND');
     $subForm->getElement('includeCategoryParentInMrss')->setChecked($extendParentCategory);
     $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++, 100);
     $this->addSubForm($mainSubForm, 'itemXpathsToExtend_group');
 }
Ejemplo n.º 6
0
 public function init()
 {
     $translator = $this->getTranslator();
     foreach (array('de', 'en') as $lang) {
         $langForm = new Zend_Form_SubForm();
         $langForm->setLegend($translator->translate("setup_language_{$lang}"));
         $keyForm = new Zend_Form_SubForm();
         $keyForm->addElement('text', 'home_index_index_pagetitle', array('label' => $translator->translate('setup_home_index_index_pagetitle'), 'attribs' => array('size' => 90)));
         $keyForm->addElement('text', 'home_index_index_title', array('label' => $translator->translate('setup_home_index_index_title'), 'attribs' => array('size' => 90)));
         $keyForm->addElement('textarea', 'home_index_index_welcome', array('label' => $translator->translate('setup_home_index_index_welcome'), 'attribs' => array('size' => 90)));
         $keyForm->addElement('textarea', 'home_index_index_instructions', array('label' => $translator->translate('setup_home_index_index_instructions'), 'attribs' => array('size' => 90)));
         $langForm->addSubForm($keyForm, 'key');
         $this->addSubForm($langForm, $lang);
     }
 }
Ejemplo n.º 7
0
 public function init()
 {
     $subForm = new Zend_Form_SubForm();
     $subForm->setLegend('adsFields');
     $validateNonZeroValue = new Zend_Validate_GreaterThan(0);
     $validateDate = new Zend_Validate_Date('Y-m-d');
     $elementUserId = new Zend_Form_Element_Hidden('user_id');
     $elementLanguageId = new Zend_Form_Element_Hidden('language_id');
     $elementActive = new Zend_Form_Element_Hidden('active');
     $elementActive->setValue(1);
     $elementAdsCategoryId = new Zend_Form_Element_Select('ads_category_id');
     $elementAdsCategoryId->setLabel('adsCategoryId');
     $elementAdsCategoryId->setMultiOptions(Ads_Categories::getSelectOptions());
     $elementAdsCategoryId->addValidator($validateNonZeroValue);
     $elementAdsCategoryId->setRequired(true);
     $elementAdsTypeId = new Zend_Form_Element_Select('ads_type_id');
     $elementAdsTypeId->setLabel('adsTypeId');
     $elementAdsTypeId->setMultiOptions(Ads_Types::getSelectOptions());
     $elementAdsTypeId->addValidator($validateNonZeroValue);
     $elementAdsTypeId->setRequired(true);
     $elementValidBefore = new Standart_Form_Element_Date('valid_until');
     $elementValidBefore->setLabel('adsValidUntil');
     $elementValidBefore->addValidator($validateDate);
     $elementValidBefore->setRequired(true);
     $elementTitle = new Zend_Form_Element_Text('title');
     $elementTitle->setLabel('adsTitle');
     $elementTitle->setAttrib('size', 75);
     $elementTitle->setRequired(true);
     $elementDescription = new Zend_Form_Element_Textarea('description');
     $elementDescription->setLabel('adsDescription');
     $elementDescription->setRequired(true);
     $captchaImage = new Zend_Captcha_Image();
     $captchaImage->setFont(Standart_Main::getDirs('fonts', 'arial.ttf'));
     $captchaImage->setFontSize(30);
     $captchaImage->setWordlen(6);
     $captchaImage->setImgDir(Standart_Main::getDirs('wwwStatic', array('images', 'captcha')));
     $captchaImage->setImgUrl(Zend_Registry::get('config')->host->static . '/images/captcha/');
     $captchaImage->setWidth(175);
     $captchaImage->setHeight(75);
     $captchaImage->setName('captcha');
     $elementCaptcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captchaImage));
     $elementDoSave = new Zend_Form_Element_Submit('doSave');
     $subForm->addElements(array($elementUserId, $elementLanguageId, $elementActive, $elementAdsCategoryId, $elementAdsTypeId, $elementValidBefore, $elementTitle, $elementDescription, $elementCaptcha));
     $this->addSubForm($subForm, 'ads');
     $this->addElement($elementDoSave);
 }
 protected function addItemXpathsToExtend($itemXpathsToExtend)
 {
     if (count($itemXpathsToExtend) == 0) {
         $itemXpathsToExtend = array(new Kaltura_Client_Type_String());
     }
     $mainSubForm = new Zend_Form_SubForm();
     $mainSubForm->setLegend('Item XPaths To Extend');
     $mainSubForm->setDecorators(array('FormElements', array('ViewScript', array('viewScript' => 'distribution-item-xpath-to-extend.phtml', 'placement' => 'APPEND')), 'Fieldset'));
     $i = 1;
     foreach ($itemXpathsToExtend as $stringObject) {
         $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true));
         $subForm->setDecorators(array('FormElements'));
         $subForm->addElement('text', 'itemXpathsToExtend', array('decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'div'))), 'isArray' => true, 'value' => $stringObject->value));
         $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++);
     }
     $this->addSubForm($mainSubForm, 'itemXpathsToExtend_group');
 }
Ejemplo n.º 9
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('cms_block')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Block Information');
     $subForm1->setDescription('Block Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $title = new Zend_Form_Element_Text('title', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $title->setRequired(true)->setLabel('Title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $identifer = new Zend_Form_Element_Text('identifier_key', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $identifer->setRequired(true)->setLabel('Identifer Key')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $content = new Uni_Core_Form_Element_Editor('content', array('cols' => '50', 'rows' => '20', 'class' => 'required'));
     $content->setRequired(true)->setLabel('Content');
     $status = new Zend_Form_Element_Select('status', array('class' => 'required'));
     $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('cms/block')->getAllStatuses());
     $subForm1->addElements(array($idField, $title, $identifer, $content, $status));
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 10
0
 public function init()
 {
     /* Form Elements & Other Definitions Here ... */
     /*
             $tablaOpcion = new Encuesta_Model_DbTable_Opcion;
     $rowsetOpciones = $tablaOpcion->fetchAll();
     
     //$eOpciones = new Zend_Form_Element_Multiselect("opciones");
     $eOpciones = new Zend_Form_Element_MultiCheckbox("opciones");
     $eOpciones->setLabel("Opciones Disponibles:");
     //$eOpciones->setAttrib("class", "form-control");
     
     foreach ($rowsetOpciones as $opcion) {
     	$eOpciones->addMultiOption($opcion->idOpcion, $opcion->opcion);
     }
     
     $eSubmit = new Zend_Form_Element_Submit("submit");
     $eSubmit->setLabel("Guardar Opciones");
     $eSubmit->setAttrib("class", "btn btn-success");
     
     $this->addElement($eOpciones);
     $this->addElement($eSubmit);
     */
     $categoriaDAO = new Encuesta_DAO_Categoria();
     $opcionDAO = new Encuesta_DAO_Opcion();
     $modelCategorias = $categoriaDAO->obtenerCategorias();
     foreach ($modelCategorias as $modelCategoria) {
         $sub = new Zend_Form_SubForm();
         $sub->setLegend($modelCategoria->getCategoria() . " :: " . $modelCategoria->getDescripcion());
         $modelOpciones = $categoriaDAO->obtenerOpciones($modelCategoria->getIdCategoria());
         $eElement = new Zend_Form_Element_MultiCheckbox($modelCategoria->getIdCategoria());
         foreach ($modelOpciones as $modelOpcion) {
             $eElement->addMultiOption($modelOpcion->getIdOpcion(), $modelOpcion->getOpcion());
         }
         $sub->addElement($eElement);
         $this->addSubForm($sub, $modelCategoria->getIdCategoria());
     }
     $eSubmit = new Zend_Form_Element_Submit("submit");
     $eSubmit->setLabel("Guardar Opciones");
     $eSubmit->setAttrib("class", "btn btn-success");
     $this->addElement($eSubmit);
 }
Ejemplo n.º 11
0
 public function init()
 {
     /* Form Elements & Other Definitions Here ... */
     $subForm = new Zend_Form_SubForm();
     $subForm->setLegend("Alta de Estado");
     $eEstado = new Zend_Form_Element_Text('estado');
     $eEstado->setLabel('Estado:');
     $eEstado->setAttrib("class", "form-control");
     $eCapital = new Zend_Form_Element_Text('capital');
     $eCapital->setLabel('Capital:');
     $eCapital->setAttrib("class", "form-control");
     $eAgregar = new Zend_Form_Element_Submit('agregar');
     $eAgregar->setLabel('Agregar');
     $eAgregar->setAttrib("class", "btn btn-primary");
     $subForm->addElements(array($eEstado, $eCapital, $eAgregar));
     //$this->addSubForm($subForm, "alta");
     //$this->addElement($eEstado);
     //$this->addElement($eAgregar);
     $this->addElements(array($eEstado, $eCapital, $eAgregar));
 }
Ejemplo n.º 12
0
 public function testGetJumpLinks()
 {
     $testForm = new Zend_Form();
     $subform = new Zend_Form_SubForm();
     $subform->setLegend('Subform 1');
     $testForm->addSubForm($subform, 'form1');
     $subform = new Zend_Form_SubForm();
     $subform->setLegend('Subform 2');
     $testForm->addSubForm($subform, 'form2');
     $subform = new Zend_Form_SubForm();
     $subform->setLegend(null);
     $testForm->addSubForm($subform, 'form3');
     $form = new Admin_Form_ActionBox($testForm);
     $links = $form->getJumpLinks();
     $this->assertEquals(2, count($links));
     $this->assertArrayHasKey('#fieldset-form1', $links);
     $this->assertEquals('Subform 1', $links['#fieldset-form1']);
     $this->assertArrayHasKey('#fieldset-form2', $links);
     $this->assertEquals('Subform 2', $links['#fieldset-form2']);
 }
Ejemplo n.º 13
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('menugroup')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Menu Group Information');
     $subForm1->setDescription('Menu Group Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $name = new Zend_Form_Element_Text('name', array('class' => 'required', 'maxlength' => 200));
     $name->setRequired(true)->setLabel('Name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $status = new Zend_Form_Element_Select('status', array('class' => 'required', 'maxlength' => 200));
     $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('navigation/menugroup')->getAllStatuses());
     $sort_order = new Zend_Form_Element_Text('sort_order', array('class' => 'required', 'maxlength' => 200));
     $sort_order->setRequired(true)->setLabel('Sort Order')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $key = new Zend_Form_Element_Text('key', array('class' => 'required', 'maxlength' => 200));
     $key->setRequired(true)->setLabel('Key')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $description = new Zend_Form_Element_Textarea('description', array('cols' => '60', 'rows' => '10'));
     $subForm1->addElements(array($idField, $name, $sort_order, $key, $status, $description));
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 14
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $userId = $this->getRequest()->getParam('id', FALSE);
     $form->setName('admin_user')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('User Information');
     $subForm1->setDescription('General User Information');
     $subForm2 = new Zend_Form_SubForm();
     $subForm2->setLegend('User Role');
     $subForm2->setDescription('User Role');
     $idField = new Zend_Form_Element_Hidden('id');
     $username = new Zend_Form_Element_Text('username', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $username->setRequired(true)->setLabel('Username')->addFilter('StripTags')->addFilter('StringTrim')->setDescription('Username should be unique')->addValidator('NotEmpty');
     $firstname = new Zend_Form_Element_Text('firstname', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $firstname->setRequired(true)->setLabel('First Name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $lastname = new Zend_Form_Element_Text('lastname', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $lastname->setRequired(true)->setLabel('Last Name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $password = new Zend_Form_Element_Password('password', array('size' => '30', 'maxlength' => 200, 'class' => !$userId ? 'required' : ''));
     if (!$userId) {
         $password->setRequired(true);
     }
     $password->setLabel('Password')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $cPassword = new Zend_Form_Element_Password('c_password', array('size' => '30', 'maxlength' => 200, 'class' => !$userId ? 'required' : ''));
     if (!$userId) {
         $cPassword->setRequired(true);
     }
     $cPassword->setLabel('Confirm Password')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $email = new Zend_Form_Element_Text('email', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $email->setRequired(true)->setLabel('Email ID')->addFilter('StripTags')->setDescription('Email ID should be unique')->addFilter('StringTrim')->addValidator('NotEmpty');
     $contact = new Zend_Form_Element_Text('contact', array('size' => '30', 'maxlength' => 200));
     $contact->setLabel('Contact')->addFilter('StripTags')->addFilter('StringTrim');
     $status = new Zend_Form_Element_Select('status', array('class' => 'required'));
     $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('admin/user')->getAllStatuses());
     $roleId = new Zend_Form_Element_Select('role_id', array('class' => 'required'));
     $roleId->setRequired(true)->setLabel('Role')->setMultiOptions(Fox::getModel('admin/role')->getUserRole());
     $subForm1->addElements(array($idField, $username, $firstname, $lastname, $email, $password, $cPassword, $contact, $status));
     $subForm2->addElements(array($roleId));
     $form->addSubForm($subForm1, 'subform1');
     $form->addSubForm($subForm2, 'subform2');
     parent::_prepareForm($form);
 }
Ejemplo n.º 15
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('contact_reply')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Contact Information');
     $subForm1->setDescription('Contact Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $name = new Zend_Form_Element_Text('name', array('size' => '30', 'maxlength' => 200, 'class' => 'required', 'readonly' => 'readonly'));
     $name->setRequired(true)->setLabel('Name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $email = new Zend_Form_Element_Text('email', array('size' => '30', 'maxlength' => 200, 'class' => 'email required', 'readonly' => 'readonly'));
     $email->setRequired(true)->setLabel('Email')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $subject = new Zend_Form_Element_Text('subject', array('size' => '30', 'maxlength' => 200, 'class' => 'required', 'readonly' => 'readonly'));
     $subject->setRequired(true)->setLabel('Subject')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $message = new Zend_Form_Element_Textarea('message', array('cols' => '30', 'rows' => '5', 'class' => 'required', 'readonly' => 'readonly'));
     $message->setRequired(true)->setLabel('Message')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $reply = new Zend_Form_Element_Textarea('reply_message', array('cols' => '30', 'rows' => '5', 'class' => 'required'));
     $reply->setRequired(true)->setLabel('Reply Message')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $subForm1->addElements(array($idField, $name, $subject, $email, $message, $reply));
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 16
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('change_password')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Change Member Password');
     $subForm1->setDescription('Change Member Password');
     $idField = new Zend_Form_Element_Hidden('id');
     $emailFieldOptions = array('size' => '30', 'maxlength' => 200, 'class' => 'required email');
     if ($this->getRequest()->getParam('id') && Fox::getModel('member/member')->load($this->getRequest()->getParam('id'))) {
         $emailFieldOptions['readonly'] = 'readonly';
     }
     $emailId = new Zend_Form_Element_Text('email_id', $emailFieldOptions);
     $emailId->setRequired(true)->setLabel('Email Id')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $password = new Zend_Form_Element_Password('password', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $password->setRequired(true)->setLabel('Password')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $cPassword = new Zend_Form_Element_Password('c_password', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $cPassword->setRequired(true)->setLabel('Confirm Password')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $subForm1->addElements(array($idField, $emailId, $password, $cPassword));
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 17
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form 
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('cms_page')->setMethod('post');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Page Information');
     $subForm1->setDescription('Page Information');
     $subForm2 = new Zend_Form_SubForm();
     $subForm2->setLegend('Layout Settings');
     $subForm2->setDescription('Page Layout Settings');
     $subForm3 = new Zend_Form_SubForm();
     $subForm3->setLegend('Meta Data');
     $subForm3->setDescription('Page Meta Data Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $title = new Zend_Form_Element_Text('title', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $title->setRequired(true)->setLabel('Title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $urlKey = new Zend_Form_Element_Text('url_key', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $urlKey->setRequired(true)->setLabel('Url Key')->addFilter('StripTags')->setDescription('Relative to Website Base URL')->addFilter('StringTrim')->addValidator('NotEmpty');
     $content = new Uni_Core_Form_Element_Editor('content', array('cols' => '50', 'rows' => '20', 'class' => 'required'));
     $content->setRequired(true)->setLabel('Content');
     $layout = new Zend_Form_Element_Select('layout', array('class' => 'required'));
     $layout->setLabel('Layout')->setRequired(true)->setMultiOptions(Fox::getModel('cms/page')->getAvailableLayouts());
     $layoutUpdate = new Zend_Form_Element_Textarea('layout_update', array('cols' => '60', 'rows' => '10'));
     $layoutUpdate->setLabel('Layout Update');
     $metaKey = new Zend_Form_Element_Textarea('meta_keywords', array('cols' => '60', 'rows' => '5'));
     $metaKey->setLabel('Meta Keywords')->addFilter('StripTags')->addFilter('StringTrim');
     $metaDesc = new Zend_Form_Element_Textarea('meta_description', array('cols' => '60', 'rows' => '5'));
     $metaDesc->setLabel('Meta Description')->addFilter('StripTags')->addFilter('StringTrim');
     $status = new Zend_Form_Element_Select('status', array('class' => 'required'));
     $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('cms/page')->getAllStatuses());
     $subForm1->addElements(array($idField, $title, $urlKey, $content, $status));
     $subForm2->addElements(array($layout, $layoutUpdate));
     $subForm3->addElements(array($metaKey, $metaDesc));
     $form->addSubForm($subForm1, 'subform1');
     $form->addSubForm($subForm2, 'subform2');
     $form->addSubForm($subForm3, 'subform3');
     parent::_prepareForm($form);
 }
Ejemplo n.º 18
0
 /**
  * Prepare form
  * 
  * @param Uni_Core_Form $form
  */
 protected function _prepareForm(Uni_Core_Form $form)
 {
     $form->setName('admin_email_template')->setMethod('post');
     $id = $this->getRequest()->getParam('id');
     $subForm1 = new Zend_Form_SubForm();
     $subForm1->setLegend('Email Template Information');
     $subForm1->setDescription('Email Template Information');
     $idField = new Zend_Form_Element_Hidden('id');
     $templateName = new Zend_Form_Element_Select('template_name', array('onchange' => 'getTemplateRecord(this)'));
     $templateName->setRequired(false)->setLabel('Template Name')->setDescription('Choose existing template to load its content')->setMultiOptions(Fox::getModel('core/email/template')->getAllTemplates());
     $name = new Zend_Form_Element_Text('name', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $name->setRequired(true)->setLabel('Name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $subject = new Zend_Form_Element_Text('subject', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $subject->setRequired(true)->setLabel('Subject')->addValidator('NotEmpty');
     $content = new Uni_Core_Form_Element_Editor('content', array('size' => '30', 'maxlength' => 200, 'class' => 'required'));
     $content->setRequired(true)->setLabel('Content')->addValidator('NotEmpty');
     if (!$id) {
         $subForm1->addElements(array($idField, $templateName, $name, $subject, $content));
     } else {
         $subForm1->addElements(array($idField, $name, $subject, $content));
     }
     $form->addSubForm($subForm1, 'subform1');
     parent::_prepareForm($form);
 }
Ejemplo n.º 19
0
 public function init()
 {
     $this->setAttrib('id', 'radio-form-app');
     // subforms
     $listener = new Zend_Form_SubForm();
     $contact = new Zend_Form_SubForm();
     $otherInfo = new Zend_Form_SubForm();
     $statement = new Zend_Form_SubForm();
     // Set subform where elements belong to avoid name clashing
     $listener->setElementsBelongTo('listenerForm');
     $contact->setElementsBelongTo('contactForm');
     $otherInfo->setElementsBelongTo('otherInfoForm');
     $statement->setElementsBelongTo('statementForm');
     //$listener->setElementDecorators(array('ViewHelper', 'Label'));
     //$statement->setElementDecorators(array('ViewHelper', 'Label'));
     // subform section names
     $listener->setLegend("LISTENER");
     $contact->setLegend("ALTERNATIVE CONTACT");
     $statement->setLegend("STATEMENT OF AGREEMENT AND RESPONSIBILITY");
     // Set the method for the display form to POST
     $this->setMethod('post');
     // ========================================================== add fields
     $this->addListenerFields($listener);
     $this->addContactFields($contact);
     $this->addOtherFields($otherInfo);
     $this->addStatementFields($statement);
     // =====================================================================
     // Add subforms to main form
     $this->addSubForms(array('listener' => $listener, 'contact' => $contact, 'otherInfo' => $otherInfo, 'statement' => $statement));
     // Add the submit button
     $this->addElement('submit', 'submit', array('id' => 'submit', 'ignore' => true, 'label' => 'Submit Application', 'class' => 'btn btn-info pull-right'));
     // Add some CSRF protection
     //        $this->addElement('hash', 'csrf', array(
     //            'ignore' => true,
     //        ));
 }
Ejemplo n.º 20
0
 /**
  * Add user attributes subform to form
  *
  * @param  Zend_Form            $form
  * @param  Newscoop\Entity\User $user
  * @return void
  */
 private function addUserAttributesSubForm(Zend_Form $form, User $user)
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $subForm = new Zend_Form_SubForm();
     $subForm->setLegend($translator->trans('User attributes', array(), 'users'));
     foreach ($user->getRawAttributes() as $key => $val) {
         $subForm->addElement('text', $key, array('label' => $key));
     }
     $subForm->setDefaults($user->getAttributes());
     $form->addSubForm($subForm, 'attributes');
 }
Ejemplo n.º 21
0
 public function populate(array $values)
 {
     $diseasesList = $this->_object->_diseasesSrc();
     $oDiseases = new DiseasesDetailsObject();
     $dData = $oDiseases->findData(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()]));
     $fieldSet = $this->getDisplayGroup('diseases');
     $i = 6;
     foreach ($diseasesList as $id => $disease) {
         $tmpForm = new FormDiseasesDetails(array('object' => $oDiseases, 'isXmlHttpRequest' => true));
         if (!empty($values['MR_Diseases']) && in_array($id, $values['MR_Diseases'])) {
             $oDiseases->setFilters(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()], 'DD_DiseaseId' => $id));
             $data = $oDiseases->getAll();
             $data[0]['DD_TypeMedic'] = explode(',', $data[0]['DD_TypeMedic']);
             $tmpForm->populate($data[0]);
         }
         $elems = $tmpForm->getElements();
         $test = new Zend_Form_SubForm();
         $test->setDisableLoadDefaultDecorators(true);
         $test->addElements($elems);
         $test->removeDecorator('DtDdWrapper');
         $test->setLegend('Détails pour ' . $disease);
         $test->setAttrib('class', 'infosFieldsetParent fieldsetDiseaseDetails');
         $test->setOrder($i++);
         $this->addSubForm($test, 'dd_' . $id);
     }
     parent::populate($values);
 }
Ejemplo n.º 22
0
 /**
  * Class constructor
  *
  * @return void
  */
 public function __construct($options)
 {
     $this->_addSubmitSaveClose = true;
     parent::__construct($options);
     $imageSrc = $options['imageSrc'];
     $dataId = $options['dataId'];
     $imgField = $options['imgField'];
     $isNewImage = $options['isNewImage'];
     $moduleName = $options['moduleName'];
     $productFormLeft = new Zend_Form_SubForm();
     $productFormRight = new Zend_Form_SubForm();
     $productFormBotPub = new Zend_Form_SubForm();
     $productFormBotPro = new Zend_Form_SubForm();
     if ($dataId == '') {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/tmp";
     } else {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp";
     }
     // hidden specify if new image for the news
     $newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage));
     $newImage->removeDecorator('Label');
     $productFormRight->addElement($newImage);
     // Name of the product line
     $name = new Zend_Form_Element_Text('PI_Name');
     $name->setLabel($productFormLeft->getView()->getCibleText('product_label_name') . "<span class='field_required'>*</span>")->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $productFormLeft->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $name->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $productFormLeft->addElement($name);
     // List of sub categories
     $oSubCategories = new SubCategoriesObject();
     $listSubCat = $oSubCategories->subcatCollection(Zend_Registry::get('currentEditLanguage'));
     $subCategories = new Zend_Form_Element_Select('P_SubCategoryID');
     $subCategories->setLabel($productFormLeft->getView()->getCibleText('form_products_subcat_label') . "<span class='field_required'>*</span>")->setAttrib('class', 'largeSelect')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $productFormLeft->getView()->getCibleText('validation_message_empty_field'))));
     $subCategories->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
     $subCategories->addMultiOptions($listSubCat);
     $productFormLeft->addElement($subCategories);
     // Checkbox for new product
     $isNewProd = new Zend_Form_Element_Checkbox('P_New');
     $isNewProd->setLabel($productFormLeft->getView()->getCibleText('form_product_isnew_label'));
     $isNewProd->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $productFormLeft->addElement($isNewProd);
     // id of the associated meta data
     $metaTagId = new Zend_Form_Element_Hidden('PI_MetaId');
     $metaTagId->removeDecorator('Label');
     $productFormLeft->addElement($metaTagId);
     // Image for the product line
     $imageTmp = new Zend_Form_Element_Hidden($imgField . '_tmp');
     $imageTmp->removeDecorator('Label');
     $productFormRight->addElement($imageTmp);
     $imageOrg = new Zend_Form_Element_Hidden($imgField . '_original');
     $imageOrg->removeDecorator('Label');
     $productFormRight->addElement($imageOrg);
     $imageView = new Zend_Form_Element_Image($imgField . '_preview', array('onclick' => 'return false;'));
     $imageView->setImage($imageSrc);
     $productFormRight->addElement($imageView);
     $imagePicker = new Cible_Form_Element_ImagePicker($imgField, array('onchange' => "document.getElementById('imageView').src = document.getElementById('" . $imgField . "').value", 'associatedElement' => $imgField . '_preview', 'pathTmp' => $pathTmp, 'contentID' => $dataId));
     $imagePicker->removeDecorator('Label');
     $productFormRight->addElement($imagePicker);
     //Keywords field
     $keywords = new Zend_Form_Element_Text('PI_MotsCles');
     $keywords->setLabel($productFormLeft->getView()->getCibleText('form_product_keywords_label'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline marginTop30', 'id' => 'title'))))->setAttrib('class', 'largeTextInput');
     $label = $keywords->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $productFormLeft->addElement($keywords);
     // Description of the product
     $descrPublic = new Cible_Form_Element_Editor('PI_DescriptionPublic', array('mode' => Cible_Form_Element_Editor::ADVANCED, 'subFormID' => 'productFormBotPub'));
     $descrPublic->setLabel($this->getView()->getCibleText('product_label_descriptionPublic'))->setAttrib('class', 'largeEditor');
     $label = $descrPublic->getDecorator('label');
     $label->setOption('class', $this->_labelCSS);
     $productFormBotPub->addElement($descrPublic);
     // Technical specs of the product for public.
     $urlTechFile = new Zend_Form_Element_Hidden('PI_FicheTechniquePublicPDF');
     $urlTechFile->removeDecorator('Label');
     $productFormBotPub->addElement($urlTechFile);
     $techfile = new Zend_Form_Element_Hidden('technicalSpecsName');
     $techfile->removeDecorator('Label');
     $productFormBotPub->addElement($techfile);
     // Technical specs of the product.
     $technicalSpecs = new Cible_Form_Element_FileManager('PI_FicheTechniquePublicPDF', array('associatedElement' => 'productFormBotPub', 'displayElement' => 'technicalSpecsName', 'pathTmp' => $this->_filePath, 'contentID' => $this->_dataId, 'setInit' => true));
     $technicalSpecs->setLabel($productFormBotPub->getView()->getCibleText('product_label_technical_specs'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $technicalSpecs->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $productFormBotPub->addElement($technicalSpecs);
     //-----------------------------------------------------
     // Description of the product for pro
     $descrPro = new Cible_Form_Element_Editor('PI_DescriptionPro', array('mode' => Cible_Form_Element_Editor::ADVANCED, 'subFormID' => 'productFormBotPro'));
     $descrPro->setLabel($this->getView()->getCibleText('product_label_descriptionPro'))->setAttrib('class', 'largeEditor');
     $label = $descrPro->getDecorator('label');
     $label->setOption('class', $this->_labelCSS);
     $productFormBotPro->addElement($descrPro);
     // Technical specs of the product for pro.
     $urlTechFile = new Zend_Form_Element_Hidden('PI_FicheTechniqueProPDF');
     $urlTechFile->removeDecorator('Label');
     $productFormLeft->addElement($urlTechFile);
     $techfile = new Zend_Form_Element_Hidden('technicalSpecsPro');
     $techfile->removeDecorator('Label');
     $productFormBotPro->addElement($techfile);
     // Technical specs of the product.
     $technicalSpecsPro = new Cible_Form_Element_FileManager('PI_FicheTechniqueProPDF', array('associatedElement' => 'productFormBotPro', 'displayElement' => 'technicalSpecsPro', 'pathTmp' => $this->_filePath, 'contentID' => $this->_dataId, 'setInit' => true));
     $technicalSpecsPro->setLabel($productFormBotPro->getView()->getCibleText('product_label_technical_specs'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $technicalSpecsPro->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $productFormBotPro->addElement($technicalSpecsPro);
     $productFormBotPub->setLegend($this->getView()->getCibleText('subform_public_legend'));
     $productFormBotPub->setAttrib('class', 'fieldsetBorder');
     $productFormBotPro->setLegend($this->getView()->getCibleText('subform_professional_legend'));
     $productFormBotPro->setAttrib('class', 'fieldsetBorder');
     $this->addSubForm($productFormLeft, 'productFormLeft');
     $this->addSubForm($productFormRight, 'productFormRight');
     $this->addSubForm($productFormBotPub, 'productFormBotPub');
     $this->addSubForm($productFormBotPro, 'productFormBotPro');
 }
Ejemplo n.º 23
0
 public function __construct($options = null)
 {
     $this->_disabledDefaultActions = true;
     parent::__construct($options);
     $this->setAttrib('id', 'accountManagement');
     $this->setAttrib('class', 'step2');
     $baseDir = $this->getView()->baseUrl();
     //Hidden fields for the state and cities id
     $selectedState = new Zend_Form_Element_Hidden('selectedState');
     $selectedState->removeDecorator('label');
     $selectedCity = new Zend_Form_Element_Hidden('selectedCity');
     $selectedCity->removeDecorator('label');
     $this->addElement($selectedState);
     $this->addElement($selectedCity);
     /* billing address */
     // Billing address
     $addressFacturationSub = new Zend_Form_SubForm();
     $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
     $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
     $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormOrder');
     $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
     $billingAddr->setProperty('addScriptState', false);
     $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $billingAddr->formAddress();
     $addrBill = new Zend_Form_Element_Hidden('addrBill');
     $addrBill->removeDecorator('label');
     $addressFacturationSub->addElement($addrBill);
     $this->addSubForm($addressFacturationSub, 'addressFact');
     /* delivery address */
     $addrShip = new Zend_Form_Element_Hidden('addrShip');
     $addrShip->removeDecorator('label');
     $addressShippingSub = new Zend_Form_SubForm();
     $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
     $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
     $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormOrder');
     $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
     $shipAddr->duplicateAddress($addressShippingSub);
     $shipAddr->setProperty('addScriptState', false);
     $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'city', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $shipAddr->formAddress();
     $addressShippingSub->addElement($addrShip);
     $this->addSubForm($addressShippingSub, 'addressShipping');
     //            $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
     //            $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')))
     //                           ->setDecorators(array(
     //                               'ViewHelper',
     //                                array('label', array('placement' => 'append')),
     //                                array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')),
     //                            ));
     //
     //            $this->addElement($termsAgreement);
     //Means of payment
     $paymentMeans = new Zend_Form_Element_Select('paymentMeans');
     $paymentMeans->setLabel($this->getView()->getCibleText('form_label_payment_means'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdTextInput')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'selectPayment'))));
     $paymentMeans->addMultiOption('', $this->getView()->getClientText('cart_details_select_choose_label'));
     $paymentMeans->addMultiOption('visa', $this->getView()->getCibleText('form_label_payement_visa'));
     $paymentMeans->addMultiOption('mastercard', $this->getView()->getCibleText('form_label_payement_mastercard'));
     $paymentMeans->addMultiOption('compte', $this->getView()->getCibleText('form_label_payement_account'));
     $paymentMeans->addMultiOption('cod', $this->getView()->getCibleText('form_label_payement_cod'));
     $this->addElement($paymentMeans);
     // Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext'))));
     $this->addElement($submit);
 }
Ejemplo n.º 24
0
 public function __construct($options = null)
 {
     $this->_disabledDefaultActions = true;
     parent::__construct($options);
     $baseDir = $this->getView()->baseUrl();
     if (!empty($options['mode']) && $options['mode'] == 'edit') {
         $this->_mode = 'edit';
     } else {
         $this->_mode = 'add';
     }
     $langId = Zend_Registry::get('languageID');
     $this->setAttrib('id', 'accountManagement');
     $this->setAttrib('class', 'step3');
     //            $addressParams = array(
     //                "fieldsValue" => array(),
     //                "display"   => array(),
     //                "required" => array(),
     //            );
     //Hidden fields for the state and cities id
     $selectedState = new Zend_Form_Element_Hidden('selectedState');
     $selectedState->removeDecorator('label');
     $selectedCity = new Zend_Form_Element_Hidden('selectedCity');
     $selectedCity->removeDecorator('label');
     $this->addElement($selectedState);
     $this->addElement($selectedCity);
     // Salutation
     $salutation = new Zend_Form_Element_Select('salutation');
     $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallTextInput')->setOrder(1);
     $greetings = $this->getView()->getAllSalutation();
     foreach ($greetings as $greeting) {
         $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
     }
     // language hidden field
     $language = new Zend_Form_Element_Hidden('language', array('value' => $langId));
     $language->removeDecorator('label');
     // langauge hidden field
     // FirstName
     $firstname = new Zend_Form_Element_Text('firstName');
     $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(2);
     // LastName
     $lastname = new Zend_Form_Element_Text('lastName');
     $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(3);
     // email
     $regexValidate = new Cible_Validate_Email();
     $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
     $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
     $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setOrder(4);
     if ($this->_mode == 'add') {
         $email->addValidator($emailNotFoundInDBValidator);
     }
     // email
     // password
     $password = new Zend_Form_Element_Password('password');
     if ($this->_mode == 'add') {
         $password->setLabel($this->getView()->getCibleText('form_label_password'));
     } else {
         $password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
     }
     $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setRequired(true)->setOrder(5)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
     // password
     // password confirmation
     $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
     if ($this->_mode == 'add') {
         $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
     } else {
         $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
     }
     $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(6)->setAttrib('class', 'stdTextInput');
     if (!empty($_POST['identification']['password'])) {
         $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
         $Identical = new Zend_Validate_Identical($_POST['identification']['password']);
         $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
         $passwordConfirmation->addValidator($Identical);
     }
     // password confirmation
     // Company name
     $company = new Zend_Form_Element_Text('company');
     $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setOrder(7)->setAttribs(array('class' => 'stdTextInput'));
     // function in company
     $functionCompany = new Zend_Form_Element_Text('functionCompany');
     $functionCompany->setLabel($this->getView()->getCibleText('form_label_account_function_company'))->setRequired(false)->setOrder(8)->setAttribs(array('class' => 'stdTextInput'));
     // Are you a retailer
     $retailer = new Zend_Form_Element_Select('isRetailer');
     $retailer->setLabel($this->getView()->getClientText('form_label_retailer'))->setAttrib('class', 'smallTextInput');
     $retailer->addMultiOption(0, $this->getView()->getCibleText('button_no'));
     $retailer->addMultiOption(1, $this->getView()->getCibleText('button_yes'));
     // Text Subscribe
     $textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
     $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->page_privacy_policy->pageID), $textSubscribe);
     // Newsletter subscription
     $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
     $newsletterSubscription->setLabel($textSubscribe);
     if ($this->_mode == 'add') {
         $newsletterSubscription->setChecked(1);
     }
     $newsletterSubscription->setAttrib('class', 'long-text');
     $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     if ($this->_mode == 'add') {
         $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
         $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')));
         $termsAgreement->setAttrib('class', 'long-text');
         $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
         $termsAgreement->setRequired(true);
         $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms')));
     } else {
         $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1));
     }
     // Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton');
     // Reference number for the job
     $txtConnaissance = new Cible_Form_Element_Html('knowYou', array('value' => $this->getView()->getCibleText('form_account_mieux_vous_connaitre_legend')));
     $txtConnaissance->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'description left'))));
     $refJobId = new Zend_Form_Element_Text('refJobId');
     $refJobId->setLabel('refJobId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Reference number for the role
     $refRoleId = new Zend_Form_Element_Text('refRoleId');
     $refRoleId->setLabel('refRoleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Reference number for the job title
     $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId');
     $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId');
     $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Provincial tax exemption
     $noProvTax = new Zend_Form_Element_Checkbox('noProvTax');
     $noProvTax->setLabel($this->getView()->getCibleText('form_label_account_provincial_tax'));
     $noProvTax->setAttrib('class', 'long-text')->setOrder(13);
     $noProvTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     // Provincial tax exemption
     $noFedTax = new Zend_Form_Element_Checkbox('noFedTax');
     $noFedTax->setLabel($this->getView()->getCibleText('form_label_account_federal_tax'));
     $noFedTax->setAttrib('class', 'long-text')->setOrder(14);
     $noFedTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     /*  Identification sub form */
     $identificationSub = new Zend_Form_SubForm();
     $identificationSub->setName('identification')->removeDecorator('DtDdWrapper');
     $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend'));
     $identificationSub->setAttrib('class', 'identificationClass subFormClass');
     $identificationSub->addElement($language);
     $identificationSub->addElement($salutation);
     $identificationSub->addElement($lastname);
     $identificationSub->addElement($firstname);
     $identificationSub->addElement($email);
     $identificationSub->addElement($password);
     $identificationSub->addElement($passwordConfirmation);
     $identificationSub->addElement($company);
     $this->addSubForm($identificationSub, 'identification');
     //            $identificationSub->addElement($functionCompany);
     $addrContactMedia = new Cible_View_Helper_FormAddress($identificationSub);
     if ($options['resume']) {
         $addrContactMedia->setProperty('addScript', false);
     }
     $addrContactMedia->enableFields(array('firstTel', 'secondTel', 'fax', 'webSite'));
     $addrContactMedia->formAddress();
     $identificationSub->addElement($noProvTax);
     $identificationSub->addElement($noFedTax);
     /*  Identification sub form */
     /* billing address */
     // Billing address
     $addressFacturationSub = new Zend_Form_SubForm();
     $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
     $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
     $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass');
     $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
     $billingAddr->setProperty('addScriptState', false);
     if ($options['resume']) {
         $billingAddr->setProperty('addScript', false);
     }
     $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $billingAddr->formAddress();
     $addrBill = new Zend_Form_Element_Hidden('addrBill');
     $addrBill->removeDecorator('label');
     $addressFacturationSub->addElement($addrBill);
     $addressFacturationSub->getElement('AI_SecondAddress')->removeDecorator('label');
     $this->addSubForm($addressFacturationSub, 'addressFact');
     /* delivery address */
     $addrShip = new Zend_Form_Element_Hidden('addrShip');
     $addrShip->removeDecorator('label');
     $addressShippingSub = new Zend_Form_SubForm();
     $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
     $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
     $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass');
     $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
     if ($options['resume']) {
         $shipAddr->setProperty('addScript', false);
     }
     $shipAddr->duplicateAddress($addressShippingSub);
     $shipAddr->setProperty('addScriptState', false);
     $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $shipAddr->formAddress();
     $addressShippingSub->addElement($addrShip);
     $this->addSubForm($addressShippingSub, 'addressShipping');
     if ($this->_mode == 'edit') {
         $this->addElement($termsAgreement);
     }
     $this->addElement($submit);
     $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext'))));
     if ($this->_mode == 'add') {
         $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement'))));
     }
 }
Ejemplo n.º 25
0
 /**
  * Class constructor
  *
  * @return void
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     $labelCSS = Cible_FunctionsGeneral::getLanguageLabelColor($options);
     $imageSrc = $options['imageSrc'];
     $dataId = $options['dataId'];
     $imgField = $options['imgField'];
     $isNewImage = $options['isNewImage'];
     $moduleName = $options['moduleName'];
     $formItemPrices = new Zend_Form_SubForm();
     $formTop = new Zend_Form_SubForm();
     $formBottom = new Zend_Form_SubForm();
     //        $this = new Zend_Form_SubForm();
     if ($dataId == '') {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/tmp";
     } else {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp";
     }
     // hidden specify if new image for the news
     //        $newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage));
     //        $newImage->removeDecorator('Label');
     //        $this->addElement($newImage);
     // Name of the product line
     $name = new Zend_Form_Element_Text('II_Name');
     $name->setLabel($this->getView()->getCibleText('item_label_name') . "<span class='field_required'>*</span>")->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $name->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $formTop->addElement($name);
     // List of products
     $oProducts = new ProductsObject();
     $listProd = $oProducts->productsCollection(Zend_Registry::get('currentEditLanguage'));
     $products = new Zend_Form_Element_Select('I_ProductID');
     $products->setLabel($this->getView()->getCibleText('form_item_products_label') . "<span class='field_required'>*</span>")->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'largeSelect')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))));
     $products->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
     $products->addMultiOptions($listProd);
     //        foreach ($listProd as $data)
     //        {
     //            $products->addMultiOption($data['P_ID'], $data['PI_Name']);
     //        }
     $formTop->addElement($products);
     // Product
     $productCode = new Zend_Form_Element_Text('I_ProductCode');
     $productCode->setLabel($this->getView()->getCibleText('form_product_code_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $formTop->addElement($productCode);
     // Item sequence
     $sequence = new Zend_Form_Element_Text('I_Seq');
     $sequence->setLabel($this->getView()->getCibleText('form_product_sequence_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $formTop->addElement($sequence);
     // Detail Price
     $detailPrice = new Zend_Form_Element_Text('I_PriceDetail');
     $detailPrice->setLabel($this->getView()->getCibleText('form_item_pricedetail_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $formTop->addElement($detailPrice);
     // Pro price
     $proPrice = new Zend_Form_Element_Text('I_PricePro');
     $proPrice->setLabel($this->getView()->getCibleText('form_item_pricepro_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $formTop->addElement($proPrice);
     //********************************************************
     //* Sub form containing data defining prices and volumes *
     //********************************************************
     $txtQty = new Cible_Form_Element_Html('lblQty', array('value' => $this->getView()->getCibleText('form_item_qty_label')));
     $txtQty->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline left'))));
     $formItemPrices->addElement($txtQty);
     $txtPrices = new Cible_Form_Element_Html('lblPrices', array('value' => $this->getView()->getCibleText('form_item_prices_label')));
     $txtPrices->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline right'))));
     $formItemPrices->addElement($txtPrices);
     // Qty limit 1
     $qtyInf = new Zend_Form_Element_Text('I_LimitVol1');
     $qtyInf->setLabel($this->getView()->getCibleText('form_item_limitvol1_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput left');
     $formItemPrices->addElement($qtyInf);
     // Price Vol 1
     $firstPrice = new Zend_Form_Element_Text('I_PriceVol1');
     $firstPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput');
     $formItemPrices->addElement($firstPrice);
     // Qty limit 2
     $qtyMiddle = new Zend_Form_Element_Text('I_LimitVol2');
     $qtyMiddle->setLabel($this->getView()->getCibleText('form_item_limitvol2_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput textRight');
     $formItemPrices->addElement($qtyMiddle);
     // Price vol 2
     $secondPrice = new Zend_Form_Element_Text('I_PriceVol2');
     $secondPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight', 'id' => 'title'))))->setAttrib('class', 'smallTextInput textRight');
     $formItemPrices->addElement($secondPrice);
     // Price vol 3
     $thirdPrice = new Zend_Form_Element_Text('I_PriceVol3');
     $thirdPrice->setLabel($this->getView()->getCibleText('form_item_priceVol3_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput textRight');
     $formItemPrices->addElement($thirdPrice);
     //********************************************************
     $special = new Zend_Form_Element_Checkbox('I_Special');
     $special->setLabel($this->getView()->getCibleText('form_item_special_label'));
     $special->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $formBottom->addElement($special);
     // Special Price
     $specialPrice = new Zend_Form_Element_Text('I_PrixSpecial');
     $specialPrice->setLabel($this->getView()->getCibleText('form_item_specialPrice_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $formBottom->addElement($specialPrice);
     // Checkbox for tax of the province
     $taxProv = new Zend_Form_Element_Checkbox('P_TaxProv');
     $taxProv->setLabel($this->getView()->getCibleText('form_item_taxprov_label'))->setAttrib('checked', 'checked');
     $taxProv->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $formBottom->addElement($taxProv);
     // Checkbox for federal tax
     $taxFed = new Zend_Form_Element_Checkbox('P_TaxFed');
     $taxFed->setLabel($this->getView()->getCibleText('form_item_taxfed_label'))->setAttrib('checked', 'checked');
     $taxFed->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $formBottom->addElement($taxFed);
     $formItemPrices->setLegend($this->getView()->getCibleText('subform_itemprices_legend'));
     $formItemPrices->setAttrib('class', 'smallFieldsetBorder');
     //        $this->setLegend($this->getView()->getCibleText('subform_professional_legend'));
     //        $this->setAttrib('class', 'fieldsetBorder');
     //        $this->addSubForm($this, 'productFormLeft');
     //        $this->addSubForm($this, 'productFormRight');
     $this->addSubForm($formTop, 'formTop');
     $this->addSubForm($formItemPrices, 'formItemPrices');
     $this->addSubForm($formBottom, 'formBottom');
 }
Ejemplo n.º 26
0
 protected function buildAutoForm()
 {
     //
     global $gANNOTATION_KEYS;
     extract($gANNOTATION_KEYS);
     if ($this->recurseSubEntities) {
         $this->addSaveButton('upper_submit');
     }
     foreach ($this->entityColumns as $propertyName => $def) {
         if (!isset($def['annotations'][$annoKeyAwe])) {
             continue;
         }
         $elementType = false;
         $element = false;
         // annotation keys
         $anno = $def['annotations'];
         // determine element type
         if (isset($anno[$annoKeyId])) {
             $elementType = 'hidden_primary_key';
         } else {
             if (isset($anno[$annoKeyM21])) {
                 $elementType = $this->recurseSubEntities ? 'foreign_dropdown' : 'hidden_foreign_key';
             } else {
                 if (isset($anno[$annoKey12m]) && $this->recurseSubEntities && $anno[$annoKeyAwe]->editInline && $this->repopData && !$this->isRestful) {
                     $elementType = 'foreign_editInline';
                 } else {
                     if (isset($anno[$annoKeyM2m])) {
                         $elementType = 'foreign_multi_checkbox';
                     } else {
                         if (isset($anno[$annoKeyCol])) {
                             $elementType = 'entity';
                         }
                     }
                 }
             }
         }
         // Render that type of element
         switch ($elementType) {
             case 'hidden_primary_key':
                 //
                 $element = new Zend_Form_Element_Hidden('id');
                 $element->setDecorators(array('ViewHelper'));
                 if ($this->repopData) {
                     $element->setValue($this->repopData->id);
                 }
                 break;
             case 'hidden_foreign_key':
                 //
                 $elementName = isset($anno[$annoKeyJoinColumn]->name) ? $anno[$annoKeyJoinColumn]->name : $propertyName . '_id';
                 $element = new Zend_Form_Element_Hidden($elementName);
                 $element->setDecorators(array('ViewHelper'));
                 $element->setValue($this->repopData->{$propertyName}->id);
                 break;
             case 'entity':
                 //
                 // setup properties
                 // use a label param if set,
                 // otherwise use the @Column annotation's name property
                 // replace underscores with spaces and capitalize each word
                 // otherwise default to the property name of the object
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $type = $anno[$annoKeyAwe]->type ? $anno[$annoKeyAwe]->type : $this->getDefaultElementType($anno[$annoKeyCol]->type);
                 $colType = $anno[$annoKeyCol]->type;
                 $params = isset($anno[$annoKeyAwe]->params) ? $anno[$annoKeyAwe]->params : array();
                 $validators = count((array) $anno[$annoKeyAwe]->validators) ? (array) $anno[$annoKeyAwe]->validators : $this->getDefaultElementValidators($anno[$annoKeyCol]);
                 // build element
                 $element = new $type($propertyName, $params);
                 $element->setLabel($label);
                 $validatorList = array();
                 foreach ($validators as $v => $args) {
                     $validatorList[] = new $v((array) $args);
                 }
                 $element->setValidators($validatorList);
                 // repopulate data
                 if ($this->repopData) {
                     if ($colType == 'datetime' || $colType == 'date') {
                         $value = $this->repopData->{$propertyName}->format('Y-m-d');
                     } else {
                         $value = $this->repopData->{$propertyName};
                     }
                     $element->setValue($value);
                 }
                 break;
             case 'foreign_dropdown':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKeyM21]->targetEntity;
                 $displayColumn = $anno[$annoKeyAwe]->displayColumn;
                 $join_column = $anno[$annoKeyJoinColumn]->name;
                 // get related entities
                 $dql = "select e from {$targetEntity} e";
                 $foreignEntities = $this->_doctrine->createQuery($dql)->getResult();
                 $dropdowns = array();
                 $dropdowns[''] = '';
                 foreach ($foreignEntities as $id => $f) {
                     $dropdowns[$f->id] = $f->{$displayColumn};
                 }
                 // build element
                 $element = new Zend_Form_Element_Select($join_column);
                 $element->setMultiOptions($dropdowns);
                 $element->setLabel($label);
                 // repopulate data
                 if ($this->repopData && $this->repopData->{$propertyName}) {
                     $element->setValue($this->repopData->{$propertyName}->id);
                 }
                 break;
             case 'foreign_multi_checkbox':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKeyM2m]->targetEntity;
                 $displayColumn = $anno[$annoKeyAwe]->displayColumn;
                 $inverseColumn = $anno[$annoKeyJoinTable]->inverseJoinColumns[0]->name;
                 $targetId = str_replace('\\', '_', $targetEntity);
                 $attribute = str_replace('_id', '', "{$inverseColumn}s");
                 // get related entities
                 $dql = "select e from {$targetEntity} e";
                 $foreignEntities = $this->_doctrine->createQuery($dql)->getResult();
                 $foreignColumns = $this->getEntityColumnDefs($targetEntity);
                 $options = array();
                 if (count($foreignEntities)) {
                     foreach ($foreignEntities as $fe) {
                         $options[$fe->id] = $fe->{$displayColumn};
                     }
                 }
                 // build element
                 $element = new Zend_Form_Element_MultiCheckbox("{$inverseColumn}s");
                 $element->setMultiOptions($options);
                 $element->setLabel($label);
                 // repopulate data
                 $values = array();
                 foreach ($this->repopData->{$attribute} as $subEntity) {
                     $values[] = $subEntity->id;
                 }
                 $element->setValue($values);
                 break;
             case 'foreign_editInline':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKey12m]->targetEntity;
                 $editInline = $anno[$annoKeyAwe]->editInline;
                 $targetId = str_replace('\\', '_', $targetEntity);
                 $subformName = "{$targetId}_subform";
                 // get sub entities
                 $sub_entities = $this->repopData->{$propertyName};
                 $subEntityColumns = $this->getEntityColumnDefs($targetEntity);
                 // build sub forms
                 $subform = new Zend_Form_SubForm();
                 $subform->setLegend($label);
                 $recurse = false;
                 $parent = $this->repopData;
                 $x = 0;
                 foreach ($sub_entities as $subEntity) {
                     $autoCrudForm = new Awe_Form_AutoMagic($subformName, $subEntityColumns, $subEntity, $recurse, $parent);
                     $subform->addSubform($autoCrudForm, $x++);
                 }
                 $this->addSubform($subform, $targetId);
                 break;
         }
         if ($element) {
             $this->getAutoSubform('entity')->addElement($element);
         }
     }
     if ($this->recurseSubEntities) {
         $this->addSaveButton('lower_submit');
     }
 }