/** * Hook for node form - if type is Filemanager Node, add extra fields * * @param Zend_Form $form * @param array $arguments */ public function nodeForm(Zend_Form &$form, &$arguments) { $item =& array_shift($arguments); if (!Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest() && $item->type == "filemanager_file") { // Add Filemanager fields $form->setAttrib('enctype', 'multipart/form-data'); $file = new Zend_Form_Element_File('filemanager_file'); $file->setLabel("Select file")->setDestination(ZfApplication::$_data_path . DIRECTORY_SEPARATOR . "files")->setRequired(false); $form->addElement($file); $fields[] = 'filemanager_file'; if ($item->id > 0) { // Fetch Filemanager object $factory = new Filemanager_File_Factory(); $file_item = $factory->find($item->id)->current(); if ($file_item) { $existing = new Zend_Form_Element_Image('filemanager_image'); if (substr($file_item->mimetype, 0, 5) == "image") { $imageid = $file_item->nid; } else { $imageid = 0; } $urlOptions = array('module' => 'filemanager', 'controller' => 'file', 'action' => 'show', 'id' => $imageid); $existing->setImage(Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, 'default')); $fields[] = 'filemanager_image'; } } $options = array('legend' => Zoo::_("File upload")); $form->addDisplayGroup($fields, 'filemanager_fileupload', $options); } else { // Add content node image selector } }
public function init() { $this->setMethod('post')->setAttrib('enctype', 'multipart/form-data'); $this->clearDecorators(); $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'div_form'))->addDecorator('Form'); $this->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'p', 'class' => 'element-group')))); $this->addElement('text', 'nombre', array('label' => 'Nombre', 'value' => '', 'required' => true, 'filters' => array('StripTags'))); $validator = new Zend_Validate_Alpha(array('allowWhiteSpace' => true)); $this->nombre->addValidator($validator); $this->nombre->setErrorMessages(array('messages' => 'El campo nombre solo puede contener letras')); $this->addElement('textarea', 'descripcion', array('label' => 'Descripcion')); $menus = new Application_Model_DbTable_TipoProductos(); $tipo_menu = $menus->select_tipoProducto(); $this->addElement('select', 'id_tipo_producto', array('label' => 'Tipo de Producto')); $this->id_tipo_producto->addmultiOptions($tipo_menu); $this->addElement('text', 'precio', array('label' => 'Precio', 'value' => '', 'required' => true, 'filters' => array('StringTrim', 'StripTags', 'StringToLower'))); $validatorDigit = new Zend_Validate_Digits(); $this->precio->addValidator($validatorDigit); $this->precio->setErrorMessages(array('messages' => 'El campo precio solo puede contener Numeros')); $this->addElement('text', 'puntos_producto', array('label' => 'Puntos', 'value' => '', 'required' => true, 'filters' => array('StringTrim', 'StripTags', 'StringToLower'))); $this->puntos_producto->addValidator($validatorDigit); $this->puntos_producto->setErrorMessages(array('messages' => 'El campo puntos solo puede contener Numeros')); $this->addElement('hidden', 'imagen'); $element = new Zend_Form_Element_File('element'); $element->setRequired(false)->setLabel('Subir Imagen')->setValueDisabled(true)->addValidator('Extension', false, 'jpg,png,gif,jpeg'); $this->addElement($element); $this->addElement('submit', 'Agregar', array('ignore' => true, 'decorators' => array(array('ViewHelper'), array('HtmlTag', array('tag' => 'p', 'class' => 'submit-group'))))); }
public function init() { /* $this->setDecorators(array( array('Description', array('tag' => 'p', 'class' => 'description','escape' => false)), 'formElements', 'fieldset', array('form',array('class' => 'formdefault')) )); $this->setElementDecorators(array( 'ViewHelper', 'Description', 'Label', 'Errors', array(array('tipo' => 'HtmlTag'), array('tag' => 'div')) ));*/ //$this->setAttrib('class','formdefault consumidorForm'); //$this->setLegend('Enviar Arquivos'); $this->setName('upload'); $this->setAttrib('enctype', 'multipart/form-data'); $description = new Zend_Form_Element_Text('description'); $description->setLabel('Description')->setRequired(true)->addValidator('NotEmpty'); $file = new Zend_Form_Element_File('arquivo'); $file->setLabel('Selecione os arquivos EDI"s Zipados')->setDestination('temp/arquivos/zip')->setRequired(true)->addValidator('Extension', false, 'zip'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Enviar'); $this->addElements(array($file, $submit)); }
public function myInit($Id) { global $mySession; $db = new Db(); if ($Id != "") { $adminData = $db->runQuery("select * from " . TSHIRT_ICONS . " where id='" . $Id . "'"); $title_value = $adminData[0]['title']; $oldicon_value = $adminData[0]['icon']; $colorcode_value = $adminData[0]['colorcode']; } else { $title_value = ''; $oldicon_value = ''; $colorcode_value = ''; } $title = new Zend_Form_Element_Text('title'); $title->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'First Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setValue($title_value); $colorcode = new Zend_Form_Element_Text('colorcode'); $colorcode->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Please enter color code.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "Expandable mws-textinput required")->setAttrib("onkeypress", "return checknummspK(event)")->setValue($colorcode_value); $this->addElement($colorcode); $this->addElement($title); if ($Id == "") { $image = new Zend_Form_Element_File('image'); $image->setDestination(SITE_ROOT . 'images/tshirt-icons/')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Please select an icon.'))->addValidator('Extension', false, 'jpg,jpeg,png,gif')->setAttrib("class", "textbox")->addDecorator('Errors', array('class' => 'error')); } else { $image = new Zend_Form_Element_File('image'); $image->setDestination(SITE_ROOT . 'images/tshirt-icons/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->setAttrib("class", "textbox"); } $this->addElement($image); if ($Id != "") { $oldicon = new Zend_Form_Element_Hidden('oldicon'); $oldicon->setValue($oldicon_value); $this->addElement($oldicon); $this->addElement("hidden", "foo", array("decorators" => array(array(array("img" => "HtmlTag"), array("tag" => "img", "openOnly" => true, "src" => IMAGES_URL . 'tshirt-icons/' . $oldicon_value, "align" => "middle", "class" => "myClass", "style" => "max-width:200px;max-height:200px;")), array("ViewHelper"), array(array("span" => "HtmlTag"), array("tag" => "span", "class" => "myElement", "style" => "text-align:center;display:block;"))))); } }
/** * upload image * * @param string $base64 */ public function uploadImage($base64 = 'no') { $tmpFile = tempnam(Tinebase_Core::getTempDir(), ''); $file = new Zend_Form_Element_File('file'); $maxsize = $file->getMaxFileSize(); $sessionId = Tinebase_Core::get(Tinebase_Session::SESSIONID); if (move_uploaded_file($_FILES['upload']['tmp_name'], $tmpFile)) { $image_id = str_replace(Tinebase_Core::getTempDir() . '/', '', $tmpFile); $image_size = filesize($tmpFile); if ($base64 === 'yes') { // converts image to base64 try { $image = file_get_contents($tmpFile); $encoded_data = base64_encode($image); echo '{"success":true , "id":"' . $image_id . '", "session_id":"' . $sessionId . '", "size":"' . $image_size . '", "path":"' . $tmpFile . '", "base64":"' . $encoded_data . '"}'; } catch (Exception $e) { echo '{"success":false, "error":' . $e . description . '}'; } } else { echo '{"success":true , "id":"' . $image_id . '", "session_id":"' . $sessionId . '", "size":"' . $image_size . '", "path":"' . $tmpFile . '"}'; } } else { echo '{"success":false, "method":"uploadImage", "maxsize":"' . $maxsize . '"}'; } }
public function __construct($options = null) { parent::__construct($options); $translate = Zend_Registry::get('Zend_Translate'); $this->setName('registercomplete_form'); $this->setAttrib('id', 'registercomplete_form'); $this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator'); $this->addElementPrefixPath('Oibs_Validators', 'OIBS/Validators/', 'validate'); $this->removeDecorator('DtDdWrapper'); $firstname = new Zend_Form_Element_Text('firstname'); $firstname->setLabel($translate->_("account-register-firstname"))->setRequired(false)->removeDecorator('DtDdWrapper')->setAttrib('id', 'registercomplete_firstname')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registrationcomplete_firstname'))))->setDecorators(array('RegistercompleteDecorator')); $surname = new Zend_Form_Element_Text('surname'); $surname->setLabel($translate->_("account-register-surname"))->setRequired(false)->removeDecorator('DtDdWrapper')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registrationcomplete_surname'))))->setAttrib('id', 'registercomplete_surname')->setDecorators(array('RegistercompleteDecorator')); $image = new Zend_Form_Element_File('image'); $image->setLabel($translate->_("account-registercomplete-add-image"))->setDestination('../www/upload')->addValidator('Count', false, 1)->addValidator('Size', false, 25600)->addValidator('Extension', false, 'jpg,png,gif')->removeDecorator('DtDdWrapper')->setAttrib('id', 'registercomplete_image')->removeDecorator('DefaultDecorator')->addDecorator('HtmlTag', array('tag' => 'div', 'id' => 'form_registercomplete_image', 'style' => 'display:block'))->addDecorator('Label', array('tag' => 'div', 'id' => 'form_registercomplete_image_label', 'style' => 'display:block')); $bio = new Zend_Form_Element_Textarea('bio'); $bio->setLabel($translate->_("account-register-bio"))->setRequired(false)->removeDecorator('DtDdWrapper')->setAttrib('id', 'registercomplete_bio')->setAttribs(array("onkeydown" => "textCounter(this,'progressbar_bio',0,160," . $translate->getLocale() . ");", "onkeyup" => "textCounter(this,'progressbar_bio',0,160," . $translate->getLocale() . ");"))->setDescription($translate->_('account-register-bio-desc'))->setDecorators(array('RegistercompleteDecorator')); // $bio_counter here... $select_str = $translate->_("account-select"); $country = new Zend_Form_Element_Select('country'); $country->setLabel($translate->_("account-register-country"))->setRequired(false)->removeDecorator('DtDdWrapper')->setMultiOptions(array($select_str, 'fi' => 'Finland'))->setAttrib('id', 'registercomplete_country')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registrationcomplete_country'))))->setDecorators(array('RegistercompleteDecorator')); $deflang = new Zend_Form_Element_Select('deflang'); $deflang->setLabel($translate->_("account-register-deflang"))->setMultiOptions(array($select_str, 'en' => 'English', 'fi' => 'Finnish'))->addFilter('StringToLower')->setRequired(false)->removeDecorator('DtDdWrapper')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registrationcomplete_deflang'))))->setAttrib('id', 'registercomplete_deflang')->setDecorators(array('RegistercompleteDecorator')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($translate->_("account-register-submit"))->removeDecorator('DtDdWrapper')->setAttrib('id', 'registercomplete_submit')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registrationcomplete_submit_div'))))->setAttrib('class', 'registrationcomplete_form_submit_' . $translate->getLocale())->setAttrib('disabled', 'true'); $this->addElements(array($firstname, $surname, $image, $bio, $country, $deflang, $submit)); $this->setAttrib('enctype', 'multipart/form-data'); $this->addDisplayGroup(array('firstname', 'surname', 'image', 'bio', 'country', 'deflang', 'submit'), 'allFields'); $this->allFields->removeDecorator('DtDdWrapper'); $this->allFields->setLegend('register-confirmations'); }
public function init() { $this->setMethod('post')->setAttrib('enctype', 'multipart/form-data'); $this->clearDecorators(); $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'div_form'))->addDecorator('Form'); $this->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'p', 'class' => 'element-group')))); $this->addElement('text', 'nombre', array('label' => 'Nombre * ', 'required' => true, 'filters' => array('StripTags'))); $validator = new Zend_Validate_Alpha(array('allowWhiteSpace' => true)); $this->nombre->setAttrib('placeholder', 'Nombre'); $this->nombre->addValidator($validator); $this->nombre->setErrorMessages(array('messages' => 'El campo nombre solo puede contener letras')); $this->addElement('text', 'apellido', array('label' => 'Apellido *', 'value' => '', 'required' => true, 'filters' => array('StripTags'))); $this->apellido->setAttrib('placeholder', 'Apellido'); $this->apellido->addValidator($validator)->setErrorMessages(array('messages' => 'El campo nombre solo puede contener letras')); $this->addElement('text', 'telefono', array('label' => 'Telefono', 'filters' => array('StringTrim', 'StripTags', 'StringToLower'))); $this->telefono->addValidator('digits')->setErrorMessages(array('messages' => 'El campo nombre solo puede contener numeros')); $this->addElement('text', 'domicilio', array('label' => 'Domicilio', 'filters' => array('StringTrim', 'StripTags'))); $this->addElement('password', 'contraseña', array('label' => 'Contraseña *', 'filters' => array('StringTrim', 'StripTags'))); $this->contraseña->addValidator('stringLength', false, array(6, 50))->setErrorMessages(array('messages' => 'La Contraseña debe tener como minimo 6 caracteres')); $this->addElement('password', 'verifypassword', array('label' => 'Verifica la Contraseña', 'required' => true, 'validators' => array(array('identical', true, array('contraseña'))))); $this->addElement('text', 'email', array('label' => 'Email *', 'required' => true, 'filters' => array('StringTrim', 'StripTags', 'StringToLower'))); $this->email->setAttrib('placeholder', '*****@*****.**'); $this->email->addValidator('EmailAddress', TRUE); $db_lookup_validator = new Zend_Validate_Db_NoRecordExists('usuarios', 'email'); $this->email->addValidator($db_lookup_validator); $element = new Zend_Form_Element_File('element'); $element->setRequired(false)->setLabel('Subir Imagen de Perfil')->setValueDisabled(true)->addValidator('Extension', false, 'jpg,png,gif,jpeg'); $this->addElement($element); $check = new Zend_Form_Element_Checkbox('check'); $check->setLabel('Acepto el envio de promociones e Informacion por parte del Restaurant *')->setUncheckedValue(null)->setRequired()->setDecorators(array('ViewHelper', 'Description', 'Errors', array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'div', 'class' => 'terminos')))); $this->addElement($check); $this->addElement('submit', 'Enviar', array('ignore' => true, 'decorators' => array(array('ViewHelper'), array('HtmlTag', array('tag' => 'p', 'class' => 'submit-group'))))); }
public function myInit() { global $mySession; $db = new Db(); $public_name = ""; $emailid_val = ""; $bio_value = ''; $old_profile_image_value = ''; $qur = $db->runquery("SELECT * FROM " . USERS . " WHERE user_id='" . $mySession->TeeLoggedID . "' "); if ($qur != "" and count($qur) > 0) { $public_name = $qur[0]['public_name']; $emailid_val = $qur[0]['emailid']; $bio_value = $qur[0]['bio']; $old_profile_image_value = $qur[0]['profile_image']; } $publicname = new Zend_Form_Element_Text('publicname'); $publicname->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Public name is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'changepasstextbox')->setValue($public_name); $bio = new Zend_Form_Element_Textarea('bio'); $bio->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Bio is required.'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib("class", "changepasstextarea")->setAttrib("style", "height:150px;width:354px;")->setAttrib("maxlength", "300")->setAttrib("placeholder", "Max 300 Characters")->setValue($bio_value); $profile_image = new Zend_Form_Element_File('profile_image'); $profile_image->setDestination(SITE_ROOT . 'images/profileimages/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib("class", "textInput")->setAttrib("style", "width:325px"); $old_profile_image = new Zend_Form_Element_Hidden('old_profile_image'); $old_profile_image->setValue($old_profile_image_value); $emailid = new Zend_Form_Element_Text('emailid'); $emailid->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Email Id is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'changepasstextbox')->setValue($emailid_val); $this->addElements(array($publicname, $emailid, $bio, $profile_image, $old_profile_image)); }
public function init() { global $mySession; $PathType = '1'; if (isset($_REQUEST['path_type'])) { $PathType = $_REQUEST['path_type']; } $video_title = new Zend_Form_Element_Text('video_title'); $video_title->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Video title is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput"); $pathtypeArr = array(); $pathtypeArr[0]['key'] = "1"; $pathtypeArr[0]['value'] = "Computer"; $pathtypeArr[1]['key'] = "2"; $pathtypeArr[1]['value'] = "You Tube Url"; $path_type = new Zend_Form_Element_Radio('path_type'); $path_type->addMultiOptions($pathtypeArr)->setAttrib("onclick", "setType(this.value);")->setValue(1); $video_path = new Zend_Form_Element_File('video_path'); $video_path->setDestination(SITE_ROOT . 'images/videos/')->addValidator('Extension', false, 'flv'); $you_tube_url = new Zend_Form_Element_Text('you_tube_url'); $you_tube_url->setAttrib("class", "textInput"); if ($PathType == '1') { $video_path->setRequired(true)->addDecorator('Errors', array('class' => 'error')); } else { $you_tube_url->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'You tube url is required.'))->addDecorator('Errors', array('class' => 'error')); } $this->addElements(array($video_title, $video_path, $you_tube_url, $path_type)); }
public function init() { $this->setName("Texto"); $this->setAttrib('accept-charset', 'utf-8'); $this->setAttrib('enctype', 'multipart/form-data'); $this->setMethod('post'); $this->addElement('hidden', 'id', '1'); $this->addElement('text', 'rotulo', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Rotulo deve ser informado'), 'breakChainOnFailure' => true), array('StringLength', false, array(0, 150))), 'required' => true, 'label' => 'Rotulo:', 'class' => 'input-long')); $this->addElement('text', 'titulo', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Titulo deve ser informado'), 'breakChainOnFailure' => true), array('StringLength', false, array(0, 150))), 'required' => true, 'label' => 'Titulo:', 'class' => 'input-long')); $this->addElement('textarea', 'comentario', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Destaque deve ser informado'), 'breakChainOnFailure' => true)), 'required' => true, 'label' => 'Destaque:', 'class' => 'ckeditor')); $this->addElement('select', 'ativo', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Status deve ser informado'), 'breakChainOnFailure' => true), array('StringLength', false, array(0, 150))), 'required' => true, 'label' => 'Status:', 'class' => 'input-short', 'MultiOptions' => array('' => '-- Selesionar --', 'Sim' => 'Sim', 'Não' => 'Não'))); $this->addElement('hidden', 'foto', '1'); $foto = new Zend_Form_Element_File('foto1'); $foto->setLabel('Foto:')->addValidator('Extension', false, array('jpg', 'png', 'gif'))->addValidator('Size', false, 1002400)->setDescription("Images")->setDestination('../public/upload/texto/'); $this->addElement($foto); $this->addElement('submit', 'enviar', array('required' => false, 'ignore' => true, 'class' => 'submit-green')); $this->addElement('button', 'Listar', array('label' => 'Listar', 'required' => false, 'ignore' => true, 'order' => '1', 'class' => 'submit-gray', 'attribs' => array('onclick' => 'List("Texto/index")'))); // decorado form com css $this->clearDecorators(); $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => '<div>', 'class' => 'module-body'))->addDecorator('Form'); $this->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Description'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'p')))); $this->getElement('foto1')->setDecorators(array('File', 'Errors', array(array('td' => 'HtmlTag'), array('tag' => 'p')), array('Label', array('tag' => 'p')), array(array('tr' => 'HtmlTag'), array('tag' => 'p')))); $this->getElement('enviar')->removeDecorator('label')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => '<fieldset>', 'id' => 'element')))); $this->getElement('Listar')->removeDecorator('label'); }
public function init() { $this->setName('f2')->setMethod('post'); $ten = new Zend_Form_Element_Text('ten'); $ten->setLabel('Tên (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator(new Zend_Validate_StringLength(0, 255))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('class' => 'text-input medium-input')); $statusOptions = array("multiOptions" => array(1 => 'Thuộc SGU', 0 => 'Liên kết trang mạng')); $is_sgu = new Zend_Form_Element_Radio('is_sgu', $statusOptions); $is_sgu->setRequired(true)->setLabel('Liên kết')->setValue('1')->setSeparator('')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $url = new Zend_Form_Element_Text('url'); $url->setLabel('Url (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator(new Zend_Validate_StringLength(0, 255))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $file = new Zend_Form_Element_File('file'); $file->setLabel('Upload hình')->setDescription('(*.jgp, *.gif, *.png , < 10MB )')->setDestination(BASE_PATH . '/upload/small/images/lien_ket')->addValidator(new Zend_Validate_File_Extension(array('jpg,gif,png')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $maxOrder = Khcn_Api::_()->getDbTable('lien_ket', 'default')->getMaxOrderItem(); $order = new Zend_Form_Element_Text('order'); $order->setLabel('Thứ tự *')->setValue($maxOrder->order + 1)->addValidator(new Zend_Validate_Int())->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('class' => 'text-input tinysmall-input')); $submitCon = new Zend_Form_Element_Submit('submitCon'); $submitCon->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $submitExit = new Zend_Form_Element_Submit('submitExit'); $submitExit->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $Url = new Zend_View_Helper_Url(); $link = $Url->url(array('module' => 'admin', 'controller' => 'lien-ket', 'action' => 'index'), null, true); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $link . '"')); $this->addElements(array($ten, $is_sgu, $url, $file, $order, $submitCon, $submitExit, $cancel)); $this->addDisplayGroup(array('submitCon', 'submitExit', 'cancel'), 'submit', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td')), array('HtmlTag', array('tag' => 'tr', 'id' => 'btn'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'lien_ket')), 'Form')); }
/** * * Change network background * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/SettingsBackground.phtml')))); // load settings $AppOptions = new Application_Model_AppOptions(); $all_meta = $AppOptions->getAllOptions(); // fields $background_image = new Zend_Form_Element_File('background'); $background_image->setDecorators(array('File', 'Errors'))->setLabel($this->translator->translate('Choose Picture (jpg, png or gif)'))->addValidator('Extension', false, 'jpg,jpeg,png,gif'); $background_color = new Zend_Form_Element_Text('background_color'); $background_color->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->setValue(isset($all_meta['background_color']) ? $all_meta['background_color'] : 'ff0000')->setErrorMessages(array($this->translator->translate('Please pick a color')))->setLabel($this->translator->translate('Background Color'))->setRequired(true)->setAttrib('class', 'form-control colorpicker-input'); $background_repeat = new Zend_Form_Element_Checkbox('background_repeat'); $background_repeat->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['background_repeat']) && $all_meta['background_repeat'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Repeat background'))->setCheckedValue("1")->setUncheckedValue("0"); $background_scroll = new Zend_Form_Element_Checkbox('background_scroll'); $background_scroll->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['background_scroll']) && $all_meta['background_scroll'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Scroll background'))->setCheckedValue("1")->setUncheckedValue("0"); $background_stretch = new Zend_Form_Element_Checkbox('background_stretch'); $background_stretch->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['background_stretch']) && $all_meta['background_stretch'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Stretch background'))->setCheckedValue("1")->setUncheckedValue("0"); $disable_image = new Zend_Form_Element_Checkbox('background_noimage'); $disable_image->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['background_noimage']) && $all_meta['background_noimage'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Disable custom image'))->setCheckedValue("1")->setUncheckedValue("0"); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($background_image, $background_repeat, $background_scroll, $background_stretch, $disable_image, $background_color, $submit)); $this->postInit(); }
public function init() { $this->setName('add_testimonial'); //$this->setAction('newExpert'); $this->setMethod('Post'); $this->setAttrib('enctype', 'multipart/form-data'); $first_name = new Zend_Form_Element_Text('first_name', array('disableLoadDefaultDecorators' => true)); $first_name->setRequired(true)->setLabel('* First Name:')->setAttrib('id', 'video_title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $last_name = new Zend_Form_Element_Text('last_name', array('disableLoadDefaultDecorators' => true)); $last_name->setRequired(true)->setLabel('* Last Name:')->setAttrib('id', 'url_video')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $email = new Zend_Form_Element_Text('email', array('disableLoadDefaultDecorators' => true)); $email->setRequired(true)->setLabel('* Email:')->setAttrib('id', 'email')->setAttrib('size', '30')->addFilter('StripTags')->addFilter('StringTrim')->setErrorMessages(array("Write Email"))->addValidator('EmailAddress', true)->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $short_description = new Zend_Form_Element_Textarea('short_description', array('disableLoadDefaultDecorators' => true)); $short_description->setRequired(true)->setAttrib("id", "short_description")->setLabel(' *Testimonial:')->setAttrib("class", "form-control")->setAttrib('ROWS', '5')->setAttrib('COLS', '3')->setErrorMessages(array("Write Description for Testimonial"))->addFilter('StringTrim'); $image1 = new Zend_Form_Element_File('image1'); //$image1->setRequired(true) $image1->addValidator('Count', false, 1)->addValidator('ImageSize', false, array('minwidth' => 100, 'maxwidth' => 400, 'minheight' => 100, 'maxheight' => 400))->addValidator('Size', false, 1000240000)->setErrorMessages(array("*Upload an image:"))->addValidator('Extension', false, 'jpg,png,gif'); // only JPEG, PNG, and GIFs $is_featured = new Zend_Form_Element_Checkbox('is_featured', array('disableLoadDefaultDecorators' => true)); $is_featured->setAttrib("id", "is_featured")->setLabel('Featured:')->setAttrib("class", "form-control")->addFilter('StripTags')->addFilter('StringTrim'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setAttrib('class', 'btn btn-lg btn-primary float-right')->removeDecorator('HtmlTag')->removeDecorator('Label')->setLabel("Save"); $this->setElementDecorators(array('Errors', 'ViewHelper', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('Label', array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))), array('first_name', 'last_name', 'email', 'short_description', 'image1', 'is_featured')); //$this->addElement('hash', 'csrf', array('ignore' => true,)); $this->addElements(array($first_name, $last_name, $image1, $email, $is_featured, $short_description, $submit)); }
public function init() { $this->setMethod("post"); $title = new Zend_Form_Element_Text("title"); $title->setAttrib("placeholder", "Title"); $title->setAttrib("class", "form-control"); $title->setLabel("Title: "); $title->setRequired(); $body = new Zend_Form_Element_Textarea("body"); $body->setAttrib("class", "form-control"); $body->setAttrib("placeholder", "Write body here...."); $body->setLabel("Body: "); $body->setAttrib("rows", "5"); $body->setAttrib("cols", "55"); $body->setRequired(); $picture = new Zend_Form_Element_File('picture'); $picture->setLabel("Picture:"); $picture->setRequired(); $picture->setDestination('/var/www/html/RNR/public/images/thread'); $stick = new Zend_Form_Element_Radio("stick"); $stick->setLabel("Sticky:"); $stick->addMultiOption("on", "on"); $stick->addMultiOption("off", "off"); $stick->setRequired(); $id = new Zend_Form_Element_Hidden("id"); $submit = new Zend_Form_Element_Submit("Submit"); $submit->setAttrib("class", "btn btn-primary"); $submit->setLabel("Save"); $rest = new Zend_Form_Element_Submit('Rest'); $rest->setAttrib("class", "btn btn-info"); $this->addElements(array($id, $title, $body, $picture, $stick, $submit, $rest)); }
public function init() { $username = new Zend_Form_Element_Text('name'); // $username = $this->createElement('text', 'name'); $username->setLabel('Username: *')->setRequired(true); //$username->addFilter(new Zend_Filter_HtmlEntities()); $username->addFilter(new Zend_Filter_StripTags()); $email = $this->createElement('text', 'email'); $email->setLabel('Email: *')->setRequired(false); $password = $this->createElement('password', 'password'); $password->setLabel('Password: *')->setRequired(true); $confirmPassword = $this->createElement('password', 'confirmPassword'); $confirmPassword->setLabel('Confirm Password: *')->setRequired(true); // $confirmPasswor = $this->createElement('text', 'image'); // $confirmPasswor->setLabel('Confirm image: *') // ->setRequired(false); $image = new Zend_Form_Element_File('image'); $image->setLabel("upload your iamge")->setDestination(APPLICATION_PATH . '/../public/data')->setRequired(true)->addValidator('Extension', false, array('jpg', 'jpeg', 'png'))->getValidator('Extension')->setMessage('This file type is not supportted.'); // $image->setDestination('/www/coff/data'); $this->setAttrib('enctype', 'multipart/form-data'); $room_no = $this->createElement('text', 'room_no'); $room_no->setLabel('Room number:')->setRequired(false); $ext = $this->createElement('text', 'ext'); $ext->setLabel('Ext:')->setRequired(false); $register = $this->createElement('submit', 'register'); $register->setLabel('Sign up')->setIgnore(true); $this->addElements(array($username, $email, $password, $confirmPassword, $image, $room_no, $ext, $register)); }
public function init() { $this->setName('f2')->setAttrib('enctype', 'multipart/form-data')->setMethod('post'); $this->addElement('Hidden', 'search', array('value' => 1)); $tieu_de = new Zend_Form_Element_Text('tieu_de'); $tieu_de->setLabel('Tiêu đề (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $cateOptions = Khcn_Api::_()->getDbTable('loai_thong_tin', 'default')->getListAssoc(); $loai_thong_tin_id = new Zend_Form_Element_Select('loai_thong_tin_id'); $loai_thong_tin_id->setLabel('Loại (*)')->addMultiOptions($cateOptions)->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input'); $statusOptions = array("multiOptions" => Default_Model_Constraints::trang_thai()); $trang_thai = new Zend_Form_Element_Radio('trang_thai', $statusOptions); $trang_thai->setRequired(true)->setLabel('Trạng thái')->setValue('1')->setSeparator('')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $noi_dung = new Zend_Form_Element_Textarea('noi_dung'); $noi_dung->setLabel('Nội dung (*)')->setRequired(true)->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'noi_dung', 'class' => 'text-input textarea')); $noi_bat = new Zend_Form_Element_Select('noi_bat'); $noi_bat->setLabel('Nổi Bật')->setRequired(true)->setValue(0)->addMultiOptions(array(0 => 'Không', 1 => 'Có'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $photo = new Zend_Form_Element_File('photo'); $photo->setLabel('Upload hình')->setDescription('(*.jgp, *.gif, *.png , < 10MB )')->setDestination(BASE_PATH . '/upload/files/thong_tin')->addValidator(new Zend_Validate_File_Extension(array('jpg,gif,png')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $submitCon = new Zend_Form_Element_Submit('submitCon'); $submitCon->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $submitExit = new Zend_Form_Element_Submit('submitExit'); $submitExit->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '"')); $this->addElements(array($loai_thong_tin_id, $tieu_de, $noi_dung, $trang_thai, $noi_bat, $photo, $submitCon, $submitExit, $cancel)); $this->addDisplayGroup(array('submitCon', 'submitExit', 'cancel'), 'submit', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form')); }
public function init() { //get user lsit $userM = new Application_Model_User(); $usersArr = $userM->getUsersList(null, '--- Select Author ---'); $this->addElement('select', 'userId', array('label' => 'Author:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select author.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $usersArr)); $categories = new Application_Model_Category(); $categoriesArr = $categories->getCategory("--- Select Category ---", "advice"); $this->addElement('select', 'categoryId', array('label' => 'Category:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select advice category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr)); $this->addElement('text', 'title', array('label' => 'Title :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice title')))), 'decorators' => $this->elementDecorators)); $this->addElement('text', 'identifire', array('label' => 'URL Re-write :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice URL Re-write')))), 'decorators' => $this->elementDecorators)); // Add an body element $this->addElement('textarea', 'content', array('label' => 'Content:', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page content')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); // Add an body element $this->addElement('textarea', 'synopsis', array('label' => 'Synopsis:', 'required' => false, 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the synopsis')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('textarea', 'metaTitle', array('label' => 'Meta Title :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page identifire')))), 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'metaKeyword', array('label' => 'Meta Keyword :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'metaDescription', array('label' => 'Meta Description :', 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'required' => false, 'decorators' => $this->elementDecorators)); $Name = new Zend_Form_Element_File('name'); $Name->setLabel('Upload an image:')->setRequired(false)->addValidator('Extension', false, 'jpg,png,gif')->clearDecorators()->addDecorators($this->fileDecorators); $this->addElements(array($Name)); $this->addElement('submit', 'savePublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Publish', 'label' => 'Save and Publish', 'decorators' => $this->buttonDecorators)); $this->addElement('submit', 'saveUnpublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Unpublish', 'label' => 'Save and Unpublish', 'decorators' => $this->buttonDecorators)); $this->addElement('submit', 'previewPage', array('required' => false, 'ignore' => true, 'title' => 'Preview Page', 'label' => 'Preview Page', 'decorators' => $this->buttonDecorators)); }
public function init() { $image = new Zend_Form_Element_File('imageLoadFile'); $image->setValueDisabled(true)->addValidator('Size', false, 1024000)->addValidator('Extension', false, 'jpg,png,gif')->setAttribs(array('class' => 'hidden', 'data-input' => 'image', 'data-upload' => '/upload/manufacture/category')); $this->addElement($image); $this->addElement('hidden', 'image'); $this->addElement('image', 'imageLoad', array('label' => null, 'class' => 'img-thumbnail', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-input' => 'image', 'title' => 'Загрузить изображение')); $this->addDisplayGroup(array('imageLoad', 'imageLoadFile', 'image'), 'imageGroup', array()); $this->addElement('hidden', 'id'); $this->addElement('hidden', 'parentId'); $this->addElement('text', 'title', array('label' => 'Заголовок страницы', 'placeholder' => 'Заголовок страницы', 'required' => true)); $refreshPath = '<button type="button" class="refreshSlugify btn btn-default" data-slugify="path" data-sourse="title"> <span class="glyphicon glyphicon-refresh"></span> </button>'; $this->addElement('text', 'path', array('label' => 'Url страницы', 'placeholder' => 'Url страницы', 'required' => true, 'prepend_btn' => $refreshPath)); $this->addDisplayGroup(array('title', 'path', 'parentId', 'id'), 'basic', array()); $this->addElement('textarea', 'description', array('label' => 'Краткое описание страницы', 'placeholder' => 'Краткое описание страницы', 'rows' => '4')); $this->addElement('textarea', 'contentMarkdown', array('label' => 'Текст на странице (markdown)', 'placeholder' => 'Текст', 'rows' => '8')); $this->addDisplayGroup(array('description', 'contentMarkdown'), 'desc', array('class' => 'tab-pane active', 'role' => 'tabpanel')); $this->addElement('text', 'metaTitle', array('label' => 'SEO title', 'placeholder' => 'meta title')); $this->addElement('textarea', 'metaDescription', array('label' => 'SEO description', 'placeholder' => 'meta description', 'rows' => '8')); $this->addElement('textarea', 'metaKeywords', array('label' => 'SEO keywords', 'placeholder' => 'meta keywords', 'rows' => '4')); $this->addDisplayGroup(array('metaTitle', 'metaDescription', 'metaKeywords'), 'seo', array('class' => 'tab-pane', 'role' => 'tabpanel')); $this->addElement('text', 'sorting', array('label' => 'Сортировка')); $this->addElement('checkbox', 'active', array('label' => 'Активность')); $this->addElement('checkbox', 'deleted', array('label' => 'Cтраница удалена')); $this->addDisplayGroup(array('sorting', 'active', 'deleted'), 'additionally', array('class' => 'tab-pane', 'role' => 'tabpanel')); $this->addElement('button', 'submit', array('label' => 'Сохранить', 'type' => 'submit', 'buttonType' => 'success', 'ignore' => true)); }
/** * Form init * */ public function init() { $this->setMethod('post'); $fileUploader = new Zend_Form_Element_File('photo'); $fileUploader->setLabel('Photo (max 2MB, JPEG)')->setAttrib('class', 'input')->setDestination(Zend_Registry::get('uploadPath')); $fileUploader->addValidator('Count', false, 1); $fileUploader->addValidator('Size', false, 2048000); $fileUploader->addValidator('Extension', false, 'jpg,jpeg'); $this->addElement($fileUploader, 'photo'); $fileUploader = new Zend_Form_Element_File('attach1'); $fileUploader->setLabel('Attachment (max 15MB)')->setAttrib('class', 'input')->setDestination(Zend_Registry::get('uploadPath')); $fileUploader->addValidator('Count', false, 1); $fileUploader->addValidator('Size', false, 15728640); $this->addElement($fileUploader, 'attach1'); $fileUploader = new Zend_Form_Element_File('attach2'); $fileUploader->setLabel('Attachment (max 15MB)')->setAttrib('class', 'input')->setDestination(Zend_Registry::get('uploadPath')); $fileUploader->addValidator('Count', false, 1); $fileUploader->addValidator('Size', false, 15728640); $this->addElement($fileUploader, 'attach2'); $fileUploader = new Zend_Form_Element_File('attach3'); $fileUploader->setLabel('Attachment (max 15MB)')->setAttrib('class', 'input')->setDestination(Zend_Registry::get('uploadPath')); $fileUploader->addValidator('Count', false, 1); $fileUploader->addValidator('Size', false, 15728640); $this->addElement($fileUploader, 'attach3'); $this->addElement('submit', 'submit', array('ignore' => true, 'class' => 'submit', 'label' => 'Add Applicant')); }
public function init() { $this->setName('add_video_link'); //$this->setAction('newExpert'); $this->setMethod('Post'); $this->setAttrib('enctype', 'multipart/form-data'); $title = new Zend_Form_Element_Text('title', array('disableLoadDefaultDecorators' => true)); $title->setRequired(true)->setLabel('* Video Title:')->setAttrib('id', 'video_title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $url_video = new Zend_Form_Element_Text('url_video', array('disableLoadDefaultDecorators' => true)); $url_video->setRequired(true)->setLabel('* Video URL:')->setAttrib('id', 'url_video')->addValidator('NotEmpty')->setAttrib("class", "form-control")->addFilter('StripTags')->addFilter('StringTrim')->removeDecorator('htmlTag'); $short_description = new Zend_Form_Element_Textarea('short_description', array('disableLoadDefaultDecorators' => true)); $short_description->setRequired(true)->setAttrib("id", "short_description")->setLabel(' *Short Description:')->setAttrib("class", "form-control")->setAttrib('ROWS', '5')->setAttrib('COLS', '3')->addFilter('StringTrim'); $video_img = new Zend_Form_Element_File('video_img'); //$video_img->setRequired(true) $video_img->addValidator('Count', false, 1)->addValidator('ImageSize', false, array('minwidth' => 100, 'maxwidth' => 1000, 'minheight' => 100, 'maxheight' => 1000))->addValidator('Size', false, 1000240000)->setErrorMessages(array("Upload an image:"))->addValidator('Extension', false, 'jpg,png,gif,jpeg'); // only JPEG, PNG, and GIFs $is_featured = new Zend_Form_Element_Checkbox('is_featured', array('disableLoadDefaultDecorators' => true)); $is_featured->setAttrib("id", "is_featured")->setLabel('Featured:')->setAttrib("class", "form-control")->addFilter('StripTags')->addFilter('StringTrim'); $is_main = new Zend_Form_Element_Checkbox('is_main', array('disableLoadDefaultDecorators' => true)); $is_main->setAttrib("id", "is_main")->setLabel('Mark main video:')->setAttrib("class", "form-control")->addFilter('StripTags')->addFilter('StringTrim'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submit-btn'); $submit->setAttrib('class', 'btn btn-lg btn-primary float-right')->removeDecorator('HtmlTag')->removeDecorator('Label')->setLabel("Save"); $this->setElementDecorators(array('Errors', 'ViewHelper', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('Label', array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))), array('title', 'short_description', 'url_video', 'video_img', 'is_featured', 'is_main')); //$this->addElement('hash', 'csrf', array('ignore' => true,)); $this->addElements(array($title, $short_description, $video_img, $url_video, $is_featured, $is_main, $submit)); }
public function __construct($options = null) { parent::__construct($options); $this->setAttrib('enctype', 'multipart/form-data'); $this->setName('AddRulerImage'); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li'))); $image = new Zend_Form_Element_File('image'); $image->setLabel('Upload an image: ')->setRequired(true)->setDestination('./images/rulers/')->addValidator('Size', false, 2097152)->addValidator('Extension', false, 'jpeg,tif,jpg,png,gif,JPG,TIFF')->setMaxFileSize(1024000)->setAttribs(array('class' => 'textInput'))->addValidator('Count', false, array('min' => 1, 'max' => 1))->addDecorator('File'); $caption = new Zend_Form_Element_Text('caption'); $caption->setLabel('Image caption')->setRequired(true)->setAttrib('size', 60)->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('You must enter a label'); $rulerID = new Zend_Form_Element_Hidden('rulerID'); $rulerID->removeDecorator('label')->removeDecorator('HtmlTag')->addValidator('Int')->setRequired(true); $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60); $this->addElement($hash); //Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Upload an image of a ruler')->setAttribs(array('class' => 'large')); $this->addElements(array($image, $rulerID, $caption, $submit))->setLegend('Add an image to a ruler profile'); $this->addDisplayGroup(array('image', 'caption'), 'details')->removeDecorator('HtmlTag'); $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->details->removeDecorator('DtDdWrapper'); $this->details->removeDecorator('HtmlTag'); $this->addDisplayGroup(array('submit'), 'submit'); $this->submit->removeDecorator('DtDdWrapper'); $this->submit->removeDecorator('HtmlTag'); }
public function init() { $this->setName('f2')->setAttrib('class', 'form_create_nhan_su'); $ho_ten = new Zend_Form_Element_Text('ho_ten'); $ho_ten->setLabel('Họ tên (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $chuc_vu = new Zend_Form_Element_Text('chuc_vu'); $chuc_vu->setLabel('Chức vụ')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $website = new Zend_Form_Element_Text('website'); $website->setLabel('Website')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $so_dien_thoai = new Zend_Form_Element_Text('so_dien_thoai'); $so_dien_thoai->setLabel('Số điện thoại')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $file = new Zend_Form_Element_File('file'); $file->setLabel('Ảnh cá nhân')->setDescription('(*.jgp, *.gif, *.png , < 10MB )')->setDestination(BASE_PATH . '/upload/files/nhan_su/')->addValidator(new Zend_Validate_File_Extension(array('jpg,gif,png')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $maxOrder = Khcn_Api::_()->getDbTable('nhan_su', 'default')->getMaxOrder(); $order = new Zend_Form_Element_Text('order'); $order->setLabel('Số thứ tự')->setValue($maxOrder)->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input tinysmall-input'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Lưu')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $url = new Zend_View_Helper_Url(); $link = $url->url(array('module' => 'admin', 'controller' => 'gioi-thieu', 'action' => 'nhan-su'), null, true); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setLabel('Không lưu')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $link . '"')); $this->addElements(array($ho_ten, $chuc_vu, $email, $website, $so_dien_thoai, $file, $order, $submit, $cancel)); $this->addDisplayGroup(array('submit', 'cancel'), 'submitbtn', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form')); }
public function __construct($options = null) { parent::__construct($options); $this->setName('WhatIDoForm'); // image, uploader $image = new Zend_Form_Element_File('Image'); $image->setLabel('Image:')->setDestination('img/profile')->addValidator('Count', false, 1)->addValidator('Size', false, 10000000)->addValidator('Extension', false, 'jpg,png,gif')->addFilter('Rename', 'WhatIDo.jpg'); // PictureCaption, string $pictureCaption = new Zend_Form_Element_Textarea('PictureCaption'); $pictureCaption->setLabel('Picture caption:')->setRequired(); // MainText, string $mainText = new Zend_Form_Element_Textarea('MainText'); $mainText->setLabel('Main text:')->setRequired(); // FooterText, string $footerText = new Zend_Form_Element_Textarea('FooterText'); $footerText->setLabel('Footer text:')->setRequired(); // LinkText, string $linkText = new Zend_Form_Element_Text('LinkText'); $linkText->setLabel('Link text:')->setRequired(); // LinkUrl, string $linkUrl = new Zend_Form_Element_Text('LinkUrl'); $linkUrl->setLabel('Link Url:')->setRequired(); // Submit button $submit = new Zend_Form_Element_Submit('Submit'); $submit->setLabel('Submit'); $this->addElements(array($image, $pictureCaption, $mainText, $footerText, $linkText, $linkUrl, $submit)); }
public function init() { $this->setName('photo_gallery'); $photo_name = new Zend_Form_Element_File('photo_name'); $photo_name->setRequired(true)->addValidator('Count', false, 1)->addValidator('FilesSize', false, array('min' => '1kB', 'max' => '5MB'))->addValidator('ImageSize', false, array('minwidth' => 10, 'minheight' => 10))->addFilter('StringTrim')->setErrorMessages(array("Upload an image"))->addValidator('Extension', false, 'jpeg,jpg,png,gif'); // only JPEG, PNG, and GIFs $caption = new Zend_Form_Element_Text('caption', array('disableLoadDefaultDecorators' => true)); $caption->setAttrib('id', 'caption')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $link = new Zend_Form_Element_Text('link', array('disableLoadDefaultDecorators' => true)); $link->setAttrib('id', 'link')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $description = new Zend_Form_Element_Textarea('description', array('disableLoadDefaultDecorators' => true)); $description->setAttrib('id', 'editor1')->setAttrib('name', 'description')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $category = new Zend_Form_Element_Select('category', array('disableLoadDefaultDecorators' => true)); $category->setAttrib("id", "category")->setAttrib("class", "dropdown form-control")->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $data = new Application_Model_PGCategory(); $results = $data->getAllCategoriesNames()->toArray(); foreach ($results as $result) { $category->addMultiOption($result['pg_cat_id'], $value = $result['category_name']); } $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submit-btn'); $submit->setAttrib('class', 'btn btn-md btn-primary float-right')->removeDecorator('HtmlTag')->removeDecorator('Label')->setLabel("Save"); $this->setElementDecorators(array('Errors', 'ViewHelper', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))), array('photo_name', 'category', 'caption', 'description', 'link')); $this->addElements(array($photo_name, $category, $caption, $description, $link, $submit)); }
public function init() { $this->setName('f2')->setAttrib('enctype', 'multipart/form-data')->setMethod('post'); $this->addElement('Hidden', 'search', array('value' => 1)); $tieu_de = new Zend_Form_Element_Text('tieu_de'); $tieu_de->setLabel('Tiêu đề (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $quan_trong = new Zend_Form_Element_Select('quan_trong'); $quan_trong->setLabel('Quan Trọng')->setRequired(true)->setValue(0)->addMultiOptions(array(0 => 'Không', 1 => 'Có'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $noi_bat = new Zend_Form_Element_Select('noi_bat'); $noi_bat->setLabel('Nổi Bật')->setRequired(true)->setValue(0)->addMultiOptions(array(0 => 'Không', 1 => 'Có'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $photo = new Zend_Form_Element_File('photo'); $photo->setLabel('Upload hình')->setDescription('(*.jgp, *.gif, *.png , < 10MB )')->setDestination(BASE_PATH . '/upload/files/tin_tuc')->addValidator(new Zend_Validate_File_Extension(array('jpg,gif,png')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $image = new Zend_Form_Element_Image('image'); $image->setLabel('')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $statusOptions = array("multiOptions" => Default_Model_Constraints::trang_thai()); $trang_thai = new Zend_Form_Element_Radio('trang_thai', $statusOptions); $trang_thai->setRequired(true)->setLabel('Trạng thái')->setValue('1')->setSeparator('')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $mo_ta_tom_tat = new Zend_Form_Element_Textarea('mo_ta_tom_tat'); $mo_ta_tom_tat->setLabel('Mô tả tóm tắt')->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'mo_ta_tom_tat', 'class' => 'textarea', 'rows' => '4')); $mo_ta_chi_tiet = new Zend_Form_Element_Textarea('mo_ta_chi_tiet'); $mo_ta_chi_tiet->setLabel('Mô tả chi tiết (*)')->setRequired(true)->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'mo_ta_chi_tiet', 'class' => 'text-input textarea')); $pdf = new Zend_Form_Element_File('pdf'); $pdf->setLabel('Upload PDF')->setDescription('(*.pdf < 10MB )')->setDestination(BASE_PATH . '/upload/files/tin_tuc')->addValidator(new Zend_Validate_File_Extension(array('pdf')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $submitCon = new Zend_Form_Element_Submit('submitCon'); $submitCon->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $submitExit = new Zend_Form_Element_Submit('submitExit'); $submitExit->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $url = new Zend_View_Helper_Url(); $link = $url->url(array('module' => 'admin', 'controller' => 'tin-tuc', 'action' => 'index'), null, true); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $link . '"')); $this->addElements(array($tieu_de, $quan_trong, $noi_bat, $photo, $image, $pdf, $trang_thai, $mo_ta_tom_tat, $mo_ta_chi_tiet, $submitCon, $submitExit, $cancel)); $this->addDisplayGroup(array('submitCon', 'submitExit', 'cancel'), 'submit', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'tin_tuc')), 'Form')); }
public function init() { // Задаём имя форме $this->setName('warehouse'); // Создаём переменную, которая будет хранить сообщение валидации $isEmptyMessage = 'Значение является обязательным и не может быть пустым'; // Создаём элемент формы – text c именем = number $image = new Zend_Form_Element_File('image'); $image->setLabel('Загрузить фотографию')->setDestination(DATA_PATH . '/public/img/')->addValidator('Size', false, '204800000')->addValidator('Extension', true, 'png,jpg,gif')->addValidator('ImageSize', false, array('minwidth' => 50, 'minheight' => 50, 'maxwidth' => 5000, 'maxheight' => 5000)); $serial = new Zend_Form_Element_Text('serial', array('class' => 'form-control')); $serial->setLabel('Серийный номер')->setAttrib('placeholder', 'S\\N:')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $isEmptyMessage)))->addValidator('regex', true, array("/^[а-яА-Яa-zA-Z0-9 \\. \\-]{3,200}\$/i", 'messages' => 'Не верный формат ввода'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('class' => 'test')), array('Label', array('tag' => 'div', 'class' => 'form-control-static')), array('Errors', array('tag' => 'div', 'class' => 'form-control-static')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $name = new Zend_Form_Element_Text('name', array('class' => 'form-control')); $name->setLabel('Название')->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty', true, array('messages' => 'Йо на, не может быть пустым'))->addValidator('regex', true, array("/^[а-яА-Яa-zA-Z0-9 \\. \\- \\s ]{3,50}\$/i", 'messages' => 'Не верный формат ввода'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('class' => 'test')), array('Label', array('tag' => 'div', 'class' => 'form-control-static')), array('Errors', array('tag' => 'div', 'class' => 'form-control-static')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $type = new Zend_Form_Element_Text('type', array('class' => 'form-control')); $type->setLabel('Тип')->setAttrib('placeholder', 'Viena,Royal,All')->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty', true, array('messages' => 'Йо на, не может быть пустым'))->addValidator('regex', true, array("/^[a-zA-Z0-9 \\- \\s]{3,20}\$/i", 'messages' => 'Не верный формат ввода'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('class' => 'test')), array('Label', array('tag' => 'div', 'class' => 'form-control-static')), array('Errors', array('tag' => 'div', 'class' => 'form-control-static')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $remain = new Zend_Form_Element_Text('remain', array('class' => 'form-control')); $remain->setLabel('Остаток')->setAttrib('placeholder', 'кол-во')->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty', true, array('messages' => 'Йо на, не может быть пустым'))->addValidator('regex', true, array("/^[0-9 \\-]{1,20}\$/i", 'messages' => 'Не верный формат ввода'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('class' => 'test')), array('Label', array('tag' => 'div', 'class' => 'form-control-static')), array('Errors', array('tag' => 'div', 'class' => 'form-control-static')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $price = new Zend_Form_Element_Text('price', array('class' => 'form-control')); $price->setLabel('Цена')->setAttrib('placeholder', 'введите цену в грн')->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty', true, array('messages' => 'Йо на, не может быть пустым'))->addValidator('regex', true, array("/^[0-9]{0,20}\$/i", 'messages' => 'Не верный формат ввода, для ввода доступны только цифры'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('class' => 'test')), array('Label', array('tag' => 'div', 'class' => 'form-control-static')), array('Errors', array('tag' => 'div', 'class' => 'form-control-static')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); // Создаём элемент hidden c именем = id $id = new Zend_Form_Element_Hidden('id'); // Указываем, что данные в этом элементе фильтруются как число int $id->addFilter('Int')->removeDecorator('label')->removeDecorator('element'); // Создаём элемент hidden c именем = id $path = new Zend_Form_Element_Hidden('path'); // Указываем, что данные в этом элементе фильтруются как число int $path->removeDecorator('label')->removeDecorator('element'); // Создаём элемент формы Submit c именем = submit $submit = new Zend_Form_Element_Submit('submit', array('class' => 'btn btn-default')); // Добавляем все созданные элементы к форме. $this->addElements(array($id, $serial, $name, $type, $remain, $price, $image, $submit, $path)); }
public function init() { $this->setName('f2')->setAttrib('enctype', 'multipart/form-data')->setMethod('post'); $this->addElement('Hidden', 'search', array('value' => 1)); $tieu_de = new Zend_Form_Element_Text('tieu_de'); $tieu_de->setLabel('Tiêu đề (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $noi_dung = new Zend_Form_Element_Textarea('noi_dung'); $noi_dung->setLabel('Nội dung (*)')->setRequired(true)->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'noi_dung', 'class' => 'text-input textarea')); $soundcloud_embed = new Zend_Form_Element_Text('soundcloud_embed'); $soundcloud_embed->setLabel('Embed SoundCloud')->setDescription('How to get SoundCloud embed code? <a href="http://help.soundcloud.com/customer/portal/articles/243751-how-can-i-put-my-track-or-playlist-on-my-site-or-blog-" target="_blank">Click here</a>')->setDecorators(array('ViewHelper', 'Errors', array('Description', array('tag' => 'div', 'escape' => false, 'placement' => 'append')), array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $youtube_embed = new Zend_Form_Element_Text('youtube_embed'); $youtube_embed->setLabel('Embed Youtube')->setDescription('How to get Youtube embed code? <a href="https://support.google.com/youtube/answer/171780?hl=en" target="_blank">Click here</a>')->setDecorators(array('ViewHelper', 'Errors', array('Description', array('tag' => 'div', 'escape' => false, 'placement' => 'append')), array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $link_nct = new Zend_Form_Element_Text('link_nct'); $link_nct->setLabel('Nhac cua tui')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $link_mp3 = new Zend_Form_Element_Text('link_mp3'); $link_mp3->setLabel('Mp3')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 90%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input large-input'); $statusOptions = array("multiOptions" => Default_Model_Constraints::trang_thai()); $trang_thai = new Zend_Form_Element_Radio('trang_thai', $statusOptions); $trang_thai->setRequired(true)->setLabel('Trạng thái')->setValue('1')->setSeparator('')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $noi_bat = new Zend_Form_Element_Select('noi_bat'); $noi_bat->setLabel('Nổi Bật')->setRequired(true)->setValue(0)->addMultiOptions(array(0 => 'Không', 1 => 'Có'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $photo = new Zend_Form_Element_File('photo'); $photo->setLabel('Upload hình')->setDescription('(*.jgp, *.gif, *.png , < 10MB )')->setDestination(BASE_PATH . '/upload/files/bai_giang')->addValidator(new Zend_Validate_File_Extension(array('jpg,gif,png')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $submitCon = new Zend_Form_Element_Submit('submitCon'); $submitCon->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $submitExit = new Zend_Form_Element_Submit('submitExit'); $submitExit->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button')); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '"')); $this->addElements(array($tieu_de, $noi_dung, $soundcloud_embed, $youtube_embed, $link_nct, $link_mp3, $trang_thai, $noi_bat, $photo, $submitCon, $submitExit, $cancel)); $this->addDisplayGroup(array('submitCon', 'submitExit', 'cancel'), 'submit', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form')); }
public function init() { $this->setMethod('post'); $subject = new \Zend_Form_Element_Text('subject'); $message = new \Zend_Form_Element_Textarea('message'); $priorityId = new \Zend_Form_Element_Select('priorityId'); $categories = new \Zend_Form_Element_Select('categories', array('multiple' => true)); $file = new \Zend_Form_Element_File('file'); $submit = new \Zend_Form_Element_Button('submit'); $cancel = new \Zend_Form_Element_Button('cancel'); $subject->setLabel('Konu:')->setAttrib('placeholder', 'Konu giriniz!')->setAttrib('class', 'form-control')->setRequired(true)->setDescription('')->setErrorMessages(array('required' => 'Bu alan zorunludur!')); $message->setLabel('Mesaj:')->setAttrib('placeholder', 'Mesaj giriniz!')->setAttrib('class', 'form-control')->setAttrib('rows', '5')->setRequired(true)->setDescription('')->setErrorMessages(array('required' => 'Bu alan zorunludur!')); $priorityId->setLabel('Öncelik:')->setAttrib('placeholder', 'Öncelik seçiniz!')->setAttrib('class', 'form-control')->setRequired(true)->setDescription('')->setErrorMessages(array('required' => 'Bu alan zorunludur!')); $categories->setLabel('Kategori:')->setAttrib('placeholder', 'Kategori seçiniz!')->setAttrib('class', 'form-control')->setRequired(true)->setDescription('')->setValidators(array('StringLength'))->setErrorMessages(array('StringLength' => 'En az bir adet seçmelisiniz!', 'reuqired' => 'Bu alan zorunludur')); $file->setLabel('File')->setAttrib('enctype', 'multipart/form-data')->setAttrib('accept', 'image/*')->setAttrib('id', 'upload')->setDestination('/var/www/destek-sistemi/web/upload')->addValidator('Count', false, 1)->addValidator('Size', false, 8388608)->addValidator('Extension', false, 'png,jpg'); $submit->setLabel('Kaydet')->setAttrib('class', 'btn btn-lg btn-primary btn-block')->setAttrib('type', 'submit'); $cancel->setLabel('İptal')->setAttrib('class', 'btn btn-md btn-default btn-block')->setAttrib('type', 'reset'); //$hash->setIgnore(true); // add elements $this->addElements(array($subject, $message, $priorityId, $categories, $file, $submit, $cancel)); // add display group $this->addDisplayGroup(array('subject', 'message', 'priorityId', 'categories', 'submit', 'cancel'), 'ticketForm'); // set decorators \EasyBib_Form_Decorator::setFormDecorator($this, \EasyBib_Form_Decorator::BOOTSTRAP_MINIMAL, 'submit', 'cancel'); }
function setForm() { $form = new Zend_Form; $form->setMethod('post')->setAction(''); //$this->setAttrib('enctype','multipart/form-data'); $file = new Zend_Form_Element_File('video_file'); //$file->setAttrib('class','file'); $file->setLabel('video_file'); $file->setRequired(true); $video_title = new Zend_Form_Element_Text('video_title'); $video_title ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống')); $video_thumbnail=new Zend_Form_Element_Textarea('video_thumbnail'); $video_thumbnail->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description = new Zend_Form_Element_Textarea('video_description'); $video_description->setAttrib('rows','7'); $video_description ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mô tả không được để trống')); $is_active = new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('is_active') ->setMultiOptions(array("1" => "Có","0" => "Không")); $file->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_title->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($file,$video_title,$video_description,$is_active,$video_thumbnail)); return $form; }
public function init() { // create elements $userId = new Zend_Form_Element_Hidden('id'); $mail = new Zend_Form_Element_Text('email'); $name = new Zend_Form_Element_Text('name'); $radio = new Zend_Form_Element_Radio('radio'); $file = new Zend_Form_Element_File('file'); $multi = new Zend_Form_Element_MultiCheckbox('multi'); $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'Figlet')); $submit = new Zend_Form_Element_Button('submit'); $cancel = new Zend_Form_Element_Button('cancel'); // config elements $mail->setLabel('Mail:')->setAttrib('placeholder', 'data please!')->setRequired(true)->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis fringilla purus eget ante ornare vitae iaculis est varius.')->addValidator('emailAddress'); $name->setLabel('Name:')->setRequired(true); $radio->setLabel('Radio:')->setMultiOptions(array('1' => PHP_EOL . 'test1', '2' => PHP_EOL . 'test2'))->setRequired(true); $file->setLabel('File:')->setRequired(true)->setDescription('Check file upload'); $multiOptions = array('view' => PHP_EOL . 'view', 'edit' => PHP_EOL . 'edit', 'comment' => PHP_EOL . 'comment'); $multi->setLabel('Multi:')->addValidator('Alpha')->setMultiOptions($multiOptions)->setRequired(true); $captcha->setLabel('Captcha:')->setRequired(true)->setDescription("This is a test"); $submit->setLabel('Save')->setAttrib('type', 'submit'); $cancel->setLabel('Cancel'); // add elements $this->addElements(array($userId, $mail, $name, $radio, $file, $captcha, $multi, $submit, $cancel)); // add display group $this->addDisplayGroup(array('email', 'name', 'radio', 'multi', 'file', 'captcha', 'submit', 'cancel'), 'users'); // set decorators EasyBib_Form_Decorator::setFormDecorator($this, EasyBib_Form_Decorator::BOOTSTRAP_MINIMAL, 'submit', 'cancel'); }