private function _buildElements() { $date = new Zend_Form_Element_Text($this->_name . "_Date"); $date->setLabel("Date de publication"); $date->addValidator(new Zend_Validate_Date(array("format" => "dd/MM/yyyy hh:mm")), true); $date->setDescription("JJ/MM/AAAA hh:mm"); $date->setAttrib("size", 16); $date->addDecorators(array("br" => new Zend_Form_Decorator_HtmlTag(array("tag" => "br", "noAttribs" => true)), "hr" => new Zend_Form_Decorator_HtmlTag(array("tag" => "hr", "noAttribs" => true)))); $active = new Zend_Form_Element_Checkbox($this->_name . "_Active"); $active->setLabel("Est Actif"); $active->removeDecorator("dtDdWrapper"); $submit = new Zend_Form_Element_Submit($this->_name . "_Submit"); $submit->setLabel("Creer"); return array($date, $active, $submit); }
public function init() { $this->decoradores = array('ViewHelper', array('Errors', array('tag' => 'div', 'style' => 'color:red;')), 'HtmlTag', 'Label'); $this->validatorLenghtCP = new Zend_Validate_StringLength(5, 5); $this->validatorLenghtCP->setMessages(array(Zend_Validate_StringLength::TOO_SHORT => 'El CP es de %min% digitos.', Zend_Validate_StringLength::TOO_LONG => 'El CP es de %max% digitos.')); // Operacion OLD /* $this->addElement( 'select', 'operacion', array( 'label' => ' ', 'required' => false, 'filters' => array('stringTrim') ) ); $operacion = array('0' => 'Alquiler', '1' => 'Venta'); $this->operacion->addMultiOptions($operacion); //$this->municipio->removeDecorator('Errors'); $this->operacion->setAttrib('class','form_select_medium'); $this->operacion->removeDecorator('HtmlTag'); $this->operacion->removeDecorator('Label'); */ $this->addElement('select', 'operacion', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); $operacion = array('0' => 'Apartamentos en alquiler', '1' => 'Habitación individual en alquiler', '2' => 'Habitación doble en alquiler'); $this->operacion->addMultiOptions($operacion); //$this->municipio->removeDecorator('Errors'); $this->operacion->setAttrib('class', 'form_select_medium'); $this->operacion->removeDecorator('HtmlTag'); $this->operacion->removeDecorator('Label'); // Tipo vivienda /* $this->addElement( 'radio', 'tipoVivienda', array( 'label' => 'Tipo de vivienda (*)', 'multiOptions' => array( 0 => 'Piso', 1 => 'Dúplex', 2 => 'Estudio', 3 => 'Ático', 4 => 'Loft', 5 => 'Casa/Chalet' ) )); $this->tipoVivienda->setValue('Piso'); $this->tipoVivienda->setAttrib('class','form_input_contact'); $this->tipoVivienda->removeDecorator('Errors'); $this->tipoVivienda->removeDecorator('HtmlTag'); $this->tipoVivienda->removeDecorator('Label'); */ //Precio / Mes $this->addElement('text', 'precio', array('label' => 'Precio / Mes (*)', 'required' => true, 'filters' => array('stringTrim'))); $this->precio->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar el precio.'))); $this->precio->addValidator('digits', true, array('messages' => array(Zend_Validate_Digits::NOT_DIGITS => 'Ingresar cantidad entera'))); $this->precio->setDecorators($this->decoradores); $this->precio->setAttrib('class', 'form_input_contact_small'); //$this->precio->removeDecorator('Errors'); $this->precio->removeDecorator('HtmlTag'); $this->precio->removeDecorator('Label'); // Deposito $this->addElement('text', 'deposito', array('label' => 'Deposito', 'required' => false, 'filters' => array('stringTrim'))); $this->deposito->setAttrib('class', 'form_input_contact_small'); $this->deposito->removeDecorator('Errors'); $this->deposito->removeDecorator('HtmlTag'); $this->deposito->removeDecorator('Label'); // Superficie /* $this->addElement( 'text', 'superficie', array( 'label' => 'Superficie (m2) (*)', 'required' => true, 'filters' => array('stringTrim') ) ); $this->superficie->addValidator('NotEmpty', true, array('messages' => array( Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar la superficie m2.' ) )); $this->superficie->addValidator('digits', true, array('messages' => array(Zend_Validate_Digits::NOT_DIGITS => 'Ingresar cantidad entera'))); $this->superficie->setDecorators($this->decoradores); $this->superficie->setAttrib('class','form_input_contact_small'); //$this->superficie->removeDecorator('Errors'); $this->superficie->removeDecorator('HtmlTag'); $this->superficie->removeDecorator('Label'); */ // Número de dormitorios $dbDormitorio = new Application_Model_DbTable_TipoDormitorio(); $dormitorios = $dbDormitorio->getDormitoriosList(); $this->addElement('select', 'numeroDormitorios', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); /* foreach($dormitorios as $key => $value){ $this->numeroDormitorios->addMultiOption($key,$value); }*/ $this->numeroDormitorios->addMultiOptions($dormitorios); //$this->numeroDormitorios->removeDecorator('Errors'); $this->numeroDormitorios->setAttrib('class', 'form_select_bit'); $this->numeroDormitorios->removeDecorator('HtmlTag'); $this->numeroDormitorios->removeDecorator('Label'); // Número de baños $dbBanyo = new Application_Model_DbTable_TipoBanyo(); $banyos = $dbBanyo->getBanyosList(); $this->addElement('select', 'numeroBanyos', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); /* foreach($banyos as $key => $value){ $this->numeroBanyos->addMultiOption($key,$value); }*/ $this->numeroBanyos->addMultiOptions($banyos); //$this->numeroBanyos->removeDecorator('Errors'); $this->numeroBanyos->setAttrib('class', 'form_select_bit'); $this->numeroBanyos->removeDecorator('HtmlTag'); $this->numeroBanyos->removeDecorator('Label'); // Titulo anuncio $this->addElement('text', 'titulo', array('label' => 'Titulo (*)', 'required' => true, 'filters' => array('stringTrim'))); $this->titulo->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar titulo del anuncio.'))); $this->titulo->setDecorators($this->decoradores); $this->titulo->setAttrib('class', 'form_input_contact'); //$this->titulo->removeDecorator('Errors'); $this->titulo->removeDecorator('HtmlTag'); $this->titulo->removeDecorator('Label'); // Descripcion completa $this->addElement('textarea', 'descripcion', array('label' => 'Descripción completa', 'required' => false, 'filters' => array('stringTrim'))); //$this->descripcion->setDecorators($this->decoradores); $this->descripcion->setAttrib('class', 'form_input_contact'); $this->descripcion->removeDecorator('Errors'); $this->descripcion->removeDecorator('HtmlTag'); $this->descripcion->removeDecorator('Label'); // Alta de suministros /* Versión para la web*/ $altaSuministros = new Zend_Form_Element_Checkbox('altaSuministros'); $altaSuministros->setLabel('Alta de suministros')->setRequired(FALSE); $altaSuministros->setUncheckedValue(0); $altaSuministros->setCheckedValue(1); $altaSuministros->setAttrib('class', 'form_input_contact_very_small'); $altaSuministros->removeDecorator('Errors'); $altaSuministros->removeDecorator('HtmlTag'); $altaSuministros->removeDecorator('Label'); $this->addElement($altaSuministros); /* $this->addElement( 'checkBox', 'altaSuministros', array ( 'label' => 'Alta de suministros', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0', ) ); $this->altaSuministros->setAttrib('class','form_input_contact_very_small'); $this->altaSuministros->removeDecorator('Errors'); $this->altaSuministros->removeDecorator('HtmlTag'); $this->altaSuministros->removeDecorator('Label'); */ // Ascensor /* $ascensor = new Zend_Form_Element_Checkbox('ascensor'); $ascensor->setLabel('Ascensor') ->setRequired(FALSE); $ascensor->setUncheckedValue(0); $ascensor->setCheckedValue(1); $ascensor->setAttrib('class','form_input_contact_very_small'); $ascensor->removeDecorator('Errors'); $ascensor->removeDecorator('HtmlTag'); $ascensor->removeDecorator('Label'); $this->addElement($ascensor); */ $this->addElement('checkBox', 'ascensor', array('label' => 'Ascensor', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); $this->ascensor->setAttrib('class', 'form_input_contact_very_small'); $this->ascensor->removeDecorator('Errors'); $this->ascensor->removeDecorator('HtmlTag'); $this->ascensor->removeDecorator('Label'); // Piso exterior $this->addElement('checkBox', 'pisoExterior', array('label' => 'Piso exterior', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); $this->pisoExterior->setAttrib('class', 'form_input_contact_very_small'); $this->pisoExterior->removeDecorator('Errors'); $this->pisoExterior->removeDecorator('HtmlTag'); $this->pisoExterior->removeDecorator('Label'); // Balcon $this->addElement('checkBox', 'balcon', array('label' => 'Balcón', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); $this->balcon->setAttrib('class', 'form_input_contact_very_small'); $this->balcon->removeDecorator('Errors'); $this->balcon->removeDecorator('HtmlTag'); $this->balcon->removeDecorator('Label'); // Amueblado /* $this->addElement( 'radio', 'amueblado', array( 'label' => '¿Amueblado?', 'multiOptions' => array( 1 => 'Si', 0 => 'No', ), )); //$this->amueblado->setAttrib('class','radio-amueblado'); $this->amueblado->removeDecorator('Errors'); $this->amueblado->removeDecorator('HtmlTag'); $this->amueblado->removeDecorator('Label'); */ // Código postal $this->addElement('text', 'codigoPostal', array('label' => 'Código Postal (*)', 'required' => true, 'filters' => array('stringTrim'))); $this->codigoPostal->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar el CP.'))); //$this->codigoPostal->addValidator('stringLength', false, array(5, 5)); $this->codigoPostal->addValidator($this->validatorLenghtCP); $this->codigoPostal->addValidator('digits', true, array('messages' => array(Zend_Validate_Digits::NOT_DIGITS => 'Sólo digitos'))); $this->codigoPostal->setDecorators($this->decoradores); $this->codigoPostal->setAttrib('class', 'form_input_contact_small'); //$this->codigoPostal->removeDecorator('Errors'); $this->codigoPostal->removeDecorator('HtmlTag'); $this->codigoPostal->removeDecorator('Label'); // Provincia $this->addElement('text', 'provincia', array('label' => 'Provincia (*)', 'required' => false, 'filters' => array('stringTrim'), 'value' => 'Barcelona')); $this->provincia->setAttrib('disabled', 'disabled'); $this->provincia->setAttrib('class', 'form_input_contact_small'); $this->provincia->removeDecorator('Errors'); $this->provincia->removeDecorator('HtmlTag'); $this->provincia->removeDecorator('Label'); // Municipio $dbMunicipio = new Application_Model_DbTable_Municipio(); $municipios = $dbMunicipio->getMunicipiosList(); $this->addElement('select', 'municipio', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); /* foreach($municipios as $key => $value){ $this->municipio->addMultiOption($key,$value); }*/ $this->municipio->addMultiOptions($municipios); //$this->municipio->removeDecorator('Errors'); $this->municipio->setAttrib('class', 'form_select_medium'); $this->municipio->removeDecorator('HtmlTag'); $this->municipio->removeDecorator('Label'); // Tipo de via $dbVias = new Application_Model_DbTable_TipoVias(); $vias = $dbVias->getViasList(); $this->addElement('select', 'tipoVia', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); /* foreach($vias as $key => $value){ $this->tipoVia->addMultiOption($key,$value); }*/ $this->tipoVia->addMultiOptions($vias); //$this->tipoVia->removeDecorator('Errors'); $this->tipoVia->setAttrib('class', 'form_select_medium'); $this->tipoVia->removeDecorator('HtmlTag'); $this->tipoVia->removeDecorator('Label'); //Nombre de la calle $this->addElement('text', 'direccion', array('label' => 'Nombre de la calle (*)', 'required' => true, 'filters' => array('stringTrim'))); $this->direccion->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar la dirección.'))); $this->direccion->setDecorators($this->decoradores); $this->direccion->setAttrib('class', 'form_input_contact'); //$this->direccion->removeDecorator('Errors'); $this->direccion->removeDecorator('HtmlTag'); $this->direccion->removeDecorator('Label'); // Nº $this->addElement('text', 'numero', array('label' => 'Nº (*)', 'required' => true, 'filters' => array('stringTrim'))); $this->numero->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Ingresar el Nº.'))); //$this->numero->addValidator('stringLength', false, array(5, 5)); //$this->numero->addValidator( $this->validatorLenghtCP ); $this->numero->addValidator('digits', true, array('messages' => array(Zend_Validate_Digits::NOT_DIGITS => 'Sólo digitos'))); $this->numero->setDecorators($this->decoradores); $this->numero->setAttrib('class', 'form_input_contact_small'); //$this->numero->removeDecorator('Errors'); $this->numero->removeDecorator('HtmlTag'); $this->numero->removeDecorator('Label'); // Bis $this->addElement('checkBox', 'bis', array('label' => 'Bis', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); $this->bis->setAttrib('class', 'form_input_contact_very_small'); $this->bis->removeDecorator('Errors'); $this->bis->removeDecorator('HtmlTag'); $this->bis->removeDecorator('Label'); // S/N $this->addElement('checkBox', 'sinNumero', array('label' => 'S/N', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); $this->sinNumero->setAttrib('class', 'form_input_contact_very_small'); $this->sinNumero->removeDecorator('Errors'); $this->sinNumero->removeDecorator('HtmlTag'); $this->sinNumero->removeDecorator('Label'); // Escalera $this->addElement('text', 'escalera', array('label' => 'Escalera (*)', 'required' => false, 'filters' => array('stringTrim'))); $this->escalera->setAttrib('class', 'form_input_contact_small'); $this->escalera->removeDecorator('Errors'); $this->escalera->removeDecorator('HtmlTag'); $this->escalera->removeDecorator('Label'); // Piso / Planta $dbPlantas = new Application_Model_DbTable_TipoPlanta(); $plantas = $dbPlantas->getPlantasList(); $this->addElement('select', 'tipoPlanta', array('label' => ' ', 'required' => false, 'filters' => array('stringTrim'))); /* foreach($plantas as $key => $value){ $this->tipoPlanta->addMultiOption($key,$value); }*/ $this->tipoPlanta->addMultiOptions($plantas); //$this->tipoPlanta->removeDecorator('Errors'); $this->tipoPlanta->setAttrib('class', 'form_select_medium'); $this->tipoPlanta->removeDecorator('HtmlTag'); $this->tipoPlanta->removeDecorator('Label'); // Puerta $this->addElement('text', 'puerta', array('label' => 'Puerta', 'required' => false, 'filters' => array('stringTrim'))); $this->puerta->setAttrib('class', 'form_input_contact_small'); $this->puerta->removeDecorator('Errors'); $this->puerta->removeDecorator('HtmlTag'); $this->puerta->removeDecorator('Label'); // Otra información $this->addElement('textarea', 'informacion', array('label' => 'Otra información', 'required' => false, 'filters' => array('stringTrim'))); $this->informacion->setAttrib('class', 'form_input_contact'); $this->informacion->removeDecorator('Errors'); $this->informacion->removeDecorator('HtmlTag'); $this->informacion->removeDecorator('Label'); $this->addElement('Submit', 'Grabar'); }
public function __construct($options = null) { $this->_addSubmitSaveClose = true; parent::__construct($options); $this->setName('page'); $imageSrc = $options['imageSrc']; $isNewImage = $options['isNewImage']; $menuId = $options['menuId']; if ($menuId == '') { $pathTmp = "../../../../../data/images/menu/tmp"; } else { $pathTmp = "../../../../../data/images/menu/{$menuId}/tmp"; } // input text for the title of the page $title = new Zend_Form_Element_Text('MenuTitle'); $title->setLabel(Cible_Translation::getCibleText('form_label_menu_title'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_field_required')))->setAttrib('class', 'stdTextInput'); $this->addElement($title); $menuItemType = new Zend_Form_Element_Radio('menuItemType'); $menuItemType->setLabel(Cible_Translation::getCibleText('form_label_menu_type'))->addMultiOption('page', Cible_Translation::getCibleText('form_label_menu_type_page'))->addMultiOption('placeholder', Cible_Translation::getCibleText('form_label_menu_type_placeholder'))->addMultiOption('external', Cible_Translation::getCibleText('form_label_menu_type_external'))->setValue('page')->setAttrib('onclick', 'javascript:openTypePanel(this.value)')->setSeparator(''); $this->addElement($menuItemType); $menuItemSecured = new Zend_Form_Element_Radio('menuItemSecured'); $menuItemSecured->setLabel(Cible_Translation::getCibleText('manage_block_secured_menu_status'))->addMultiOption('0', Cible_Translation::getCibleText('button_no'))->addMultiOption('1', Cible_Translation::getCibleText('button_yes'))->setValue('0')->setSeparator(''); $this->addElement($menuItemSecured); $controllerName = new Zend_Form_Element_Text('ControllerName'); $controllerName->setLabel(Cible_Translation::getCibleText('form_label_menu_destination_page'))->setAttrib('onfocus', "openPagePicker('page-picker-pagePicker');")->setRequired(true)->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_field_required')))->setAttrib('class', 'stdTextInput'); $this->addElement($controllerName); $pagePicker = new Cible_Form_Element_PagePicker('pagePicker', array('menu' => 'Principal', 'associatedElement' => 'ControllerName', 'onclick' => "javascript:closePagePicker(\"page-picker-pagePicker\")")); $pagePicker->setLabel(Cible_Translation::getCibleText('form_label_page_picker'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_page_selection_required'))); $pagePicker->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => "page-picker", 'id' => "page-picker-pagePicker")))); $this->addElement($pagePicker); $this->addDisplayGroup(array('ControllerName', 'pagePicker'), 'pageSelectionGroup'); $this->getDisplayGroup('pageSelectionGroup')->setAttrib('class', 'pageSelectionGroup')->removeDecorator('DtDdWrapper'); $link = new Zend_Form_Element_Text('MenuLink'); $link->setLabel(Cible_Translation::getCibleText('form_label_menu_destination_link'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_field_required')))->addPrefixPath('Cible', 'Cible')->setAttrib('class', 'stdTextInput'); $this->addElement($link); // input text for the css li $style = new Zend_Form_Element_Text('MenuTitleStyle'); $style->setLabel(Cible_Translation::getCibleText('form_label_menu_title_style'))->setAttrib('class', 'stdTextInput'); $this->addElement($style); $this->addDisplayGroup(array('MenuLink'), 'externalLinkSelectionGroup'); $this->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('class', 'externalLinkSelectionGroup')->setAttrib('style', 'display: none')->removeDecorator('DtDdWrapper'); // Uses image $loadImage = new Zend_Form_Element_Checkbox('loadImage'); $loadImage->setLabel($this->getView()->getCibleText('form_label_menu_load_image')); $loadImage->removeDecorator('DtDdWrapper'); $loadImage->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); // Show this menu item $MID_Show = new Zend_Form_Element_Checkbox('MID_Show'); $MID_Show->setValue(1); $MID_Show->setLabel($this->getView()->getCibleText('form_label_menu_show_item')); $MID_Show->removeDecorator('DtDdWrapper'); $MID_Show->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $this->addElement($MID_Show); $this->addElement($loadImage); // hidden specify if new image for the news $newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage)); $newImage->removeDecorator('Label'); $this->addElement($newImage); // To allow to display title and image $imgTitle = new Zend_Form_Element_Checkbox('menuImgAndTitle'); $imgTitle->setLabel($this->getView()->getCibleText('form_label_menu_display_image_and_title')); $imgTitle->removeDecorator('DtDdWrapper'); $imgTitle->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $this->addElement($imgTitle); // IMAGE $imageTmp = new Zend_Form_Element_Hidden('menuImage_tmp'); $imageTmp->removeDecorator('Label'); $this->addElement($imageTmp); $imageOrg = new Zend_Form_Element_Hidden('menuImage_original'); $imageOrg->removeDecorator('Label'); $this->addElement($imageOrg); $imageView = new Zend_Form_Element_Image('menuImage_preview', array('onclick' => 'return false;')); $imageView->setImage($imageSrc)->removeDecorator('DtDdWrapper'); $this->addElement($imageView); $imagePicker = new Cible_Form_Element_ImagePicker('menuImage', array('onchange' => "document.getElementById('imageView').src = document.getElementById('menuImage').value", 'associatedElement' => 'menuImage_preview', 'pathTmp' => $pathTmp, 'contentID' => $menuId)); $imagePicker->removeDecorator('Label'); $this->addElement($imagePicker); $this->addDisplayGroup(array('menuImgAndTitle', 'isNewImage', 'menuImage_tmp', 'menuImage_original', 'menuImage_preview', 'menuImage'), 'imageGroup'); $this->getDisplayGroup('imageGroup')->setAttrib('class', 'imageGroup')->setAttrib('style', 'display: none')->removeDecorator('DtDdWrapper'); }
public function getCheckBox($id, $value = "", $elementequired = false) { $element = new Zend_Form_Element_Checkbox($id); $element->removeDecorator('HtmlTag'); $element->removeDecorator('DtDdWrapper'); $element->removeDecorator('Label'); $element->setValue($value); if ($elementequired) { $element->setAttribs(array('class' => 'validate[required]')); } return $element; }