/** * Form init * */ public function init() { $this->setMethod('post'); $this->addElement('text', 'first_name', array('label' => 'First Name*', 'placeholder' => 'e.g. John', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'))); $this->addElement('text', 'last_name', array('label' => 'Last Name*', 'placeholder' => 'e.g. Smith', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'))); //http://stackoverflow.com/questions/8014011/queyring-database-for-existing-username-with-zend-and-doctrine $this->addElement('text', 'username', array('label' => 'Username*', 'placeholder' => 'e.g. smithj01', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', true, array('min' => 4, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Account username must be at least %min% characters'))), array('Regex', true, array('pattern' => '/^\\w(?:[\\w\\d\\.\\-_]+)(?:\\w|\\d)$/', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => "The username contained invalid characters")))))); $frmPassword1 = new Zend_Form_Element_Password('password', 'password', array('validators' => array(array('StringLength', false, array('min' => 6, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Password must be at least %min% characters long.')))))); $frmPassword1->setLabel('Password*')->setAttrib('class', 'col-md-7 col-xs-1 form-control input')->setRequired('true')->addFilter(new Zend_Filter_StringTrim()); //->addValidator('StringLength', false, array(6, 20)) $this->addElement($frmPassword1); $frmPassword2 = new Zend_Form_Element_Password('confirm_password'); $frmPassword2->setLabel('Confirm Password*')->setAttrib('class', 'col-md-7 col-xs-1 form-control input')->setRequired('true')->addFilter(new Zend_Filter_StringTrim())->addValidator('StringLength', false, array(6, 20))->addValidator(new Zend_Validate_Identical('password')); $this->addElement($frmPassword2); // $this->addElement('text', 'password', array( // 'label' => 'Password (Visible!)*', // 'class' => 'input', // 'required' => true, // 'filters' => array('StringTrim'), // 'validators' => array( // array('validator' => 'StringLength', 'options' => array(6, 20)) // ) // )); $this->addElement('select', 'role', array('label' => 'Role*', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => array('reviewer' => 'reviewer', 'admin' => 'admin'))); $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'); $this->addElement('submit', 'submit', array('ignore' => true, 'class' => 'submit', 'label' => 'Add User')); }
public function init() { $this->setMethod('post'); $element = new Zend_Form_Element_File('imageUpload'); $element->setLabel('选择要上传的图片:') ->setDestination('images/upload') ->setRequired(true); // ensure only 1 file $element->addValidator('Count', false, 1); // limit to 100K $element->addValidator('Size', false, 2024000); // only JPEG, PNG, and GIFs $element->addValidator('Extension', false, 'jpg'); $this->addElement($element, 'imageUpload'); $this->addElement( 'textarea', 'description', array( 'label' => '图片描述:', 'class'=>'tbText', 'cols'=> 60, 'rows'=> 4 ) ); $this->addElement( 'submit','submit',array( 'ignore'=>true, 'class'=>'btUploadImage radius', 'name'=>'上传' ) ); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setName('blogEntryForm'); $this->addPrefixPath('Application_Form_Decorator', APPLICATION_PATH . '/forms/decorators/', 'decorator'); $categoryForm = new Admin_Form_CategorySelect(array('categories' => $this->getCategories())); $element = $categoryForm->getElement('categoryId'); $this->addElement($element); $this->addElement('text', 'postDateAsString', array('label' => 'Post Date:', 'attribs' => array('maxlength' => 10, 'size' => 30), 'required' => true, 'validators' => array(array('Date', false, array('format' => 'dd/MM/YYYY'))), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'postdate-element')), 'RequiredLabel'))); $this->addElement('hidden', 'useExisting', array('required' => true, 'value' => 0, 'decorators' => array('ViewHelper'))); $element = new Zend_Form_Element_File('image'); $element->setValueDisabled(true); $element->setLabel('Upload an image:'); $element->addValidator('Count', false, 1); $element->addValidator('Size', false, 9000000); $element->addValidator('Extension', false, 'jpg,png,gif'); $this->addElement($element, 'image'); $this->addElement('text', 'title', array('label' => 'Title:', 'attribs' => array('maxlength' => 128, 'size' => 30), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 255))), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'title-element')), 'RequiredLabel'))); $this->addElement('textarea', 'summary', array('label' => 'Summary:', 'attribs' => array('cols' => 60, 'rows' => 6), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength')), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'summary-element')), 'RequiredLabel'))); $this->addElement('textarea', 'content', array('label' => 'Content:', 'attribs' => array('cols' => 50, 'rows' => 6), 'required' => false, 'decorators' => array('ViewHelper', 'Wysiwyg', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'content-element')), 'WarningLinkLabel'))); $this->addElement('textarea', 'content', array('label' => 'Content:', 'attribs' => array('cols' => 50, 'rows' => 6), 'required' => false, 'decorators' => array('ViewHelper', 'Wysiwyg', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'content-element')), 'WarningLinkLabel'))); $this->addElement('submit', 'submit', array('label' => 'Submit', 'Description' => 'Fields marked with an asterisk (*) are required', 'ignore' => true, 'decorators' => array('ViewHelper', 'Description', array('HtmlTag', array('tag' => 'dd', 'id' => 'submit-element')), array('Label', array('tag' => 'dt', 'style' => 'display:none'))))); $this->addElement('hash', 'csrf', array('ignore' => true, 'decorators' => array('ViewHelper'))); $this->addElement('hidden', 'id', array('ignore' => false, 'decorators' => array('ViewHelper'))); }
public function getAddContentForm($submitLabel, $contentTitle = null, $contentDescription = null) { $database = Zend_Db_Table::getDefaultAdapter(); $content = $database->select()->from('content')->order('content_id DESC')->query()->fetch(); $imageName = $content['content_id'] + 1; $form = new Zend_Form(); $form->setMethod('post'); if ($submitLabel == 'Add Content!') { $form->setAttrib('enctype', 'multipart/form-data'); $image = new Zend_Form_Element_File('foo'); $image->setLabel('Upload an image:')->setDestination('../images'); $image->addFilter('Rename', array('target' => $imageName . '.jpg', 'overwrite' => TRUE)); $image->addValidator('Count', false, 1); $image->addValidator('Extension', false, 'jpg,png,gif'); $form->addElement($image, 'foo'); } $title = $form->createElement('text', 'title'); $title->setRequired(true); $title->setValue($contentTitle); $title->setLabel('Title'); $form->addElement($title); $description = $form->createElement('textarea', 'description', array('rows' => 10)); $description->setRequired(true); $description->setValue($contentDescription); $description->setLabel('Description'); $form->addElement($description); $form->addElement('submit', 'submit', array('label' => $submitLabel)); return $form; }
public function init() { $registry = Zend_Registry::getInstance(); $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE); $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER); $signedUserInfo = $registry->get('signedUserInfo'); $uploadStatus = $registry->get("uploadStatus"); $this->setAttrib('enctype', 'multipart/form-data'); $this->setMethod('post'); $file = new Zend_Form_Element_File('file'); $file->setRequired(false); $file->setLabel('What do you want to share today?'); if ($uploadStatus['bandwidth']['remainingbytes'] > 0) { $maxFileSize = $uploadStatus['filesize']['maxbytes']; } else { $maxFileSize = 0; } $file->addValidator('Size', false, $maxFileSize); $file->setMaxFileSize($maxFileSize); $file->setMultiFile(4); $file->addValidator('Count', false, array('min' => 0, 'max' => 4)); $this->addElement($file, 'file'); $this->addElement(Ml_Model_MagicCookies::formElement()); $this->addElement('submit', 'submitupload', array('label' => 'Upload!', 'class' => 'btn primary')); $this->setAttrib('class', 'form-stacked'); }
/** * 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->setMethod('post'); $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE); $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER); $registry = Zend_Registry::getInstance(); $authedUserInfo = $registry->get('authedUserInfo'); $uploadStatus = $registry->get("uploadStatus"); $this->setAttrib('enctype', 'multipart/form-data'); $this->setMethod('post'); $file = new Zend_Form_Element_File('file'); $file->setLabel('Files:'); $file->setRequired(true); $file->addValidator('Count', false, array('min' => 1, 'max' => 1)); if ($uploadStatus['bandwidth']['remainingbytes'] > 0) { $maxFileSize = $uploadStatus['filesize']['maxbytes']; } else { $maxFileSize = 0; } $file->addValidator('Size', false, $maxFileSize); // hack for not showing 'the file exceeds the defined form size' $file->setMaxFileSize($maxFileSize * 2); /*$file->setMultiFile(1);*/ $this->addElement($file, 'file'); $title = $this->addElement('text', 'title', array('label' => 'Title:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 100))))); $short = $this->addElement('text', 'short', array('label' => 'Short description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 120))))); $description = $this->addElement('textarea', 'description', array('label' => 'Description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 4096))))); }
protected function buildFileUpload() { $tenantFromIdentity = OpenSKOS_Db_Table_Tenants::fromIdentity(); // We always need tenant for getting icon path. if (null !== $tenantFromIdentity) { $iconUpload = new Zend_Form_Element_File('icon'); $iconUpload->setLabel('Upload a new icon:')->addValidator('Count', false, 1)->setRequired(true); $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor'); if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['uploadPath'])) { $iconUpload->setDestination(APPLICATION_PATH . $editorOptions['schemeIcons']['uploadPath'] . '/' . $tenantFromIdentity->code); } else { $iconUpload->setDestination(APPLICATION_PATH . self::DEFAULT_UPLOAD_PATH . '/' . $tenantFromIdentity->code); } if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['allowedExtensions'])) { $iconUpload->addValidator('Extension', false, $editorOptions['schemeIcons']['allowedExtensions']); } else { $iconUpload->addValidator('Extension', false, 'jpg, jpeg, png, gif'); } if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['maxSize'])) { $iconUpload->addValidator('Size', false, $editorOptions['schemeIcons']['maxSize']); $iconUpload->setMaxFileSize($editorOptions['schemeIcons']['maxSize']); } else { $iconUpload->addValidator('Size', false, 2097152); $iconUpload->setMaxFileSize(2097152); } $this->addElement($iconUpload, 'icon'); } return $this; }
public function __construct($options = null) { parent::__construct($options); $this->setName('product'); $product_name = new Zend_Form_Element_Text('product_name'); $product_name->setLabel('Product Name: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $id = new Zend_Form_Element_Hidden('id'); $ProductIdExists = new Zend_Validate_Db_NoRecordExists(array('table' => 'products', 'field' => 'product_id')); $ProductIdExists->setMessage('This Product ID is already taken'); $product_id = new Zend_Form_Element_Text('product_id'); $product_id->setLabel('Product ID: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator($ProductIdExists)->addValidator('NotEmpty'); $category = new Category(); $categoriesList = $category->getCategoriesList(); $category_id = new Zend_Form_Element_Select('category_id'); $category_id->setLabel('Category: ')->addMultiOptions($categoriesList)->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $product_desc = new Zend_Form_Element_Text('product_desc'); $product_desc->setLabel('Description ')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $product_img = new Zend_Form_Element_File('product_image'); $product_img->setLabel('Upload an image:')->setDestination(PUBLIC_PATH . '/images'); // ensure only 1 file $product_img->addValidator('Count', false, 1); // limit to 100K $product_img->addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $product_img->addValidator('Extension', false, 'jpg,png,gif'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $this->setAttrib('enctype', 'multipart/form-data'); $this->addElements(array($product_name, $product_id, $product_desc, $product_img, $id, $category_id, $submit)); }
protected function tvinciElements() { // Ingest Configuration $this->addElement('text', 'ingest_url', array('label' => 'Ingest url:', 'filters' => array('StringTrim'))); $this->addElement('text', 'username', array('label' => 'Username:'******'filters' => array('StringTrim'))); $this->addElement('text', 'password', array('label' => 'Password:'******'filters' => array('StringTrim'))); $this->addDisplayGroup(array('ingest_url', 'username', 'password'), 'ingest', array('legend' => 'Ingest URL Configuration', 'decorators' => array('FormElements', 'Fieldset'))); // tag specific configuration $this->addTagItems("ism"); $this->addTagItems("ipadnew"); $this->addTagItems("iphonenew"); $this->addTagItems("mbr"); $this->addTagItems("dash"); $this->addTagItems("widevine"); $this->addTagItems("widevine_mbr"); // xslt configuration $this->addElement('file', 'xsltFile', array('label' => 'XSLT:')); $element = new Zend_Form_Element_File('xsltFile'); $element->setLabel('XSLT:'); // limit only 1 file $element->addValidator('Count', true, 1); // limit to 100K (the default one is 31K) $element->addValidator('Size', true, 102400); // only XML related file extensions $element->addValidator('Extension', true, 'xml,xslt,xsl'); $element->addValidator(new XSLTFileValidator()); $this->addElement($element, 'xsltFile'); $this->addElement('textarea', 'xsltFileText', array('label' => 'XSLT Data:', 'rows' => '2', 'cols' => '50', 'readonly' => '1')); $this->addDisplayGroup(array('xsltFile', 'xsltFileText'), 'additional', array('legend' => 'Additional Configuration', 'decorators' => array('FormElements', 'Fieldset'))); }
public function init() { $this->setAttribs(array('id' => 'form-exposicao-add')); // exposicao_nome $exposicao_nome = new Zend_Form_Element_Text("exposicao_nome"); $exposicao_nome->setLabel("Nome da Exposição:"); $exposicao_nome->setAttrib('placeholder', 'Digite o nome de sua exposição'); $exposicao_nome->setRequired(); //exposicao_descricao $exposicao_descricao = new Zend_Form_Element_Textarea("exposicao_descricao"); $exposicao_descricao->setLabel("Descrição da Exposição:"); $exposicao_descricao->setAttrib('placeholder', 'Conte aos usuários sobre sua exposição'); $exposicao_descricao->setAttrib('rows', 10); $exposicao_descricao->setRequired(); // tipo_exposicao_id $tipo_exposicao_id = new Zend_Form_Element_Select("tipo_exposicao_id"); $tipo_exposicao_id->setLabel("Categoria da Exposição:"); $tipo_exposicao_id->setRequired(); $tipo_exposicao_id->setMultiOptions($this->getTipoExposicao()); //exposicao_capa $exposicao_capa = new Zend_Form_Element_File("files"); $exposicao_capa->setLabel("Selecione a capa:"); $exposicao_capa->setDestination(Zend_Registry::get('config')->path->images->exposicao->capa); $exposicao_capa->addValidator('Extension', false, 'jpg,png,gif'); $exposicao_capa->addValidator('Size', false, 2097152)->setMaxFileSize(2097152); $exposicao_capa->setAttrib('id', 'exposicao_capa'); $exposicao_capa->setRequired(); // add elements $this->addElement($exposicao_nome); $this->addElement($exposicao_descricao); $this->addElement($tipo_exposicao_id); $this->addElement($exposicao_capa); parent::init(); }
public function init() { $media_library_model = new Cms_Model_MediaLibraries(); $media_library = $media_library_model->getByPath($this->_attribs['media_library_path']); $title = new Zend_Form_Element_Text('title'); $title->setLabel('Title'); $title->setRequired(true); $title->addFilter('StringTrim'); $title->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $this->addElement($title); $description = new Zend_Form_Element_Textarea('description'); $description->setLabel('Description'); $description->addFilter('StringTrim'); $description->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $this->addElement($description); $original = new Zend_Form_Element_File('original'); $original->addValidator('Count', false, 1); $original->addValidator('Extension', false, 'jpeg,jpg,png'); $original->addFilter('Rename', $this->_attribs['file_name']); $original->setDestination(My_Utilities::getUploadMediaPathDiffSizes($this->_attribs['file_name'], $this->_attribs['media_library_path'], 'original')); $original->setLabel('Image:'); $this->addElement($original); $submit = new Zend_Form_Element_Submit('save'); $submit->setAttrib('class', 'btn btn-primary'); $submit->setLabel('Potvrdi'); $this->setAction('')->setMethod('post')->addElement($submit); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setLabel('Cancel'); $cancel->setAttrib('class', 'btn btn-gold')->setAttrib('style', 'color:black'); $cancel->setAttrib("onClick", "window.location = window.location.origin+'/cms/medias/index/library_id/" . $media_library->id . "'"); $this->addElement($cancel); }
public function init() { $this->setMethod('post'); $this->setAttrib('enctype', 'multipart/form-data'); $photo = new Zend_Form_Element_File('photo'); $photo->setLabel('photo.upload'); $photo->setDestination($this->getAttrib('tmp')); $photo->addValidator('Count', false, 1); $photo->addValidator('Size', false, $this->getAttrib('filesize')); $photo->addValidator( 'Extension', false, $this->getAttrib('extensions') ); $photo->setRequired(true); $photo->removeDecorator('Errors'); $this->addElement($photo, 'photo'); $fbId = new Zend_Form_Element_Hidden('fbid'); $fbId->addValidator( 'Db_NoRecordExists', false, array( 'table' => 'zdjecia', 'field' => 'fbuserid' ) ); $fbId->setLabel('fbid'); $fbId->setRequired(true); $fbId->removeDecorator('Errors'); $fbId->removeDecorator('Label'); $this->addElement($fbId); $save = new Zend_Form_Element_Submit('Save'); $save->setLabel('Zgłoś Zdjęcie'); $save->setAttrib('class', 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'); $this->addElement($save); $this->addDecorator( new Zend_Form_Decorator_FormErrors( array( 'ignoreSubForms'=>true, 'markupListStart' => '<ul class="ui-state-error ui-corner-all">', ) ) ) ->addDecorator('FormElements') ->addDecorator('HtmlTag') ->addDecorator('Form'); }
function init() { parent::init(); $this->addElement(new Zend_Form_Element_Hidden('idMarca')); $this->addElement(new Zend_Form_Element_Text('nombreMarca', array('label' => 'Nombre Marca:', 'required' => true, 'maxlength' => '100', 'validators' => array('NoRecordExists' => new Zend_Validate_Db_NoRecordExists(array('table' => 'marca', 'field' => 'NombreMarca')), 'AlfaNum' => new Zend_Validate_Alnum(true)), 'size' => '40'))); $this->addElement(new Zend_Form_Element_Image('imagenUpload')); $element = new Zend_Form_Element_File('imagenMarca'); $element->setLabel('Upload an image:')->setDestination(APPLICATION_PATH . '/../public/dinamic/img/marca/'); $element->addValidator('Count', false, 1); $element->addValidator('Size', false, 1024000); $element->addValidator('Extension', false, 'jpg,png,gif'); $this->addElement($element); $this->addElement(new Zend_Form_Element_Submit('Enviar', array('attribs' => array('class' => 'submit-button')))); }
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($option = null) { parent::__construct($option); $this->setName('Addphotos'); $this->setAttrib('class', 'input-group'); $image = new Zend_Form_Element_File('image'); $image->setLabel('Зураг оруулах:'); $image->addValidator('Size', false, 1024000000); $image->addValidator('Extension', false, 'jpg,png,gif,pdf,zip,rar'); $image->setAttrib('class', "form-control"); $add = new Zend_Form_Element_Submit('add'); $add->setLabel('Хадгалах')->setAttrib('class', 'btn'); $this->addElement($image); $this->addElement($add); $this->setMethod('post'); }
public function init() { $this->setName('add_new_post'); $this->setMethod('Post'); $this->setAttrib('encrypt', 'multipart/form-data'); $heading = new Zend_Form_Element_Text('heading', array('disableLoadDefaultDecorators' => true)); $heading->setRequired(true)->setLabel('* Blog Post Title:')->setAttrib('id', 'heading')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $url = new Zend_Form_Element_Text('url'); $url->setRequired(true)->setAttrib('id', 'url')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control set-txt")->removeDecorator('htmlTag'); $description = new Zend_Form_Element_Textarea('description', array('disableLoadDefaultDecorators' => true)); $description->setRequired(true)->setLabel('* Description:')->setAttrib('id', 'description')->setAttrib('contenteditable', 'true')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); /*$categories = new Zend_Form_Element_Text('categories',array('disableLoadDefaultDecorators' =>true)); $categories->setLabel(' Category:') ->setAttrib('id', 'categories') ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('NotEmpty') ->setAttrib("class", "form-control") ->removeDecorator('htmlTag');*/ $is_comment = new Zend_Form_Element_Checkbox('is_comment', array('disableLoadDefaultDecorators' => true)); $is_comment->setAttrib("id", "is_comment")->setLabel('Mark as No Comments:')->setAttrib("class", "form-control")->addFilter('StripTags')->addFilter('StringTrim'); $tags = new Zend_Form_Element_Text('tags', array('disableLoadDefaultDecorators' => true)); $tags->setLabel('Tags:')->setAttrib('id', 'tags')->setAttrib('placeholder', 'Separate tags with comma,')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib("class", "form-control")->removeDecorator('htmlTag'); $image = new Zend_Form_Element_File('image'); $image->addValidator('Count', false, 1)->addValidator('ImageSize', false, array('minwidth' => 700, 'maxwidth' => 1000, 'minheight' => 500))->addValidator('Size', false, 1000240000)->setErrorMessages(array("Upload an image:"))->addValidator('Extension', false, 'jpg,png,gif,jpeg,jpg'); // only JPEG, PNG, and GIFs $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("Publish"); $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('heading', 'is_comment', 'url', 'image', 'description', 'tags')); $this->addElements(array($heading, $url, $is_comment, $image, $description, $tags, $submit)); }
public function testValidationShouldProxyToAdapter() { $this->markTestIncomplete('Unsure how to accurately test'); $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter()); $this->element->addValidator('Regex', '/([a-z0-9]{13})$/i'); $this->assertTrue($this->element->isValid('foo.jpg')); }
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)); }
/** * Form init * */ public function init() { $this->setMethod('post'); $this->addElement('text', 'first_name', array('label' => 'First Name*', 'placeholder' => 'e.g. John', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'))); $this->addElement('text', 'last_name', array('label' => 'Last Name*', 'placeholder' => 'e.g. Smith', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'))); $this->addElement('text', 'birth_date', array('label' => 'Birth Date*', 'icon' => 'calendar', 'placeholder' => 'e.g. 1982-10-01', 'class' => 'datepicker', 'required' => true)); $dateValidator = new Zend_Validate_Date('YYYY-MM-DD'); $this->getElement('birth_date')->addValidator($dateValidator); $seniorities = array('' => 'Select a seniority...'); foreach (My_Model::get('Seniorities')->fetchAll() as $seniority) { $seniorities[$seniority->getId()] = $seniority->getName(); } $this->addElement('select', 'seniority_id', array('label' => 'Seniority*', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => $seniorities)); $technologies = array('' => 'Select a technology...'); foreach (My_Model::get('Technologies')->fetchAll() as $technology) { $technologies[$technology->getId()] = $technology->getName(); } $this->addElement('select', 'technology_id', array('label' => 'Technology*', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => $technologies)); $positions = array('' => 'Select a position...'); foreach (My_Model::get('Positions')->fetchAll() as $position) { $positions[$position->getId()] = $position->getName(); } $this->addElement('select', 'position_id', array('label' => 'Position*', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => $positions)); $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'); $this->addElement('textarea', 'note', array('label' => 'Note', 'placeholder' => 'Interesting facts about the applicant...', 'class' => 'col-md-7 col-xs-1 form-control input textarea', 'filters' => array('StringTrim'))); $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('figure'); $this->setIsArray(true); $this->name = new Zend_Form_Element_Text('name'); $this->image = new Zend_Form_Element_File('image'); $this->description = new Zend_Form_Element_Textarea('description'); $this->draft = new Zend_Form_Element_Submit('draft'); $this->submit = new Zend_Form_Element_Submit('submit'); $this->name->setRequired(true)->setAttrib('class', 'span6'); $this->description->setRequired(true); $this->draft->setAttrib('class', 'btn'); $this->submit->setAttrib('class', 'btn btn-success'); $this->image->addValidator(new Zend_Validate_File_Extension('jpg')); $this->addElements(array($this->name, $this->image, $this->description, $this->draft, $this->submit)); $this->setElementDecorators(array('ViewHelper', 'Errors'), array('image'), false); $this->image->setDecorators(array('File')); }
public static function getUploadForm() { $form = new Zend_Form(); $form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/uploadForm.phtml')), 'Errors')); $f = new Zend_Form_Element_File('file'); //, array ('label' => 'Веберіть файл пакету') ); // $f->setAttrib ( 'style', 'width: 600px' ); $f->setRequired(); $f->addValidator('Count', false, 1); // $f->addValidator ( 'Size', false, 204800 ); $f->addValidator('Extension', false, 'xls'); $cfg = Zend_Registry::get('cfg'); $target = $cfg['temp']['path'] . Zend_Auth::getInstance()->getIdentity()->NODEID . '.xls'; $f->addFilter('Rename', array('target' => $target, 'overwrite' => 'true')); $form->addElement($f); $e = new Zend_Form_Element_Submit('submit', array('label' => 'Завантажити')); $form->addElement($e); return $form; }
function init() { parent::init(); $this->setMethod('Post'); $this->setAttrib('enctype', 'multipart/form-data'); $this->addElement(new Zend_Form_Element_Hidden('id')); $this->addElement(new Zend_Form_Element_Select('categoria', array('label' => 'categoria', 'multioptions' => CST_Utils::fetchPairs(Application_Entity_CategoriaSolucion::listarCategoriaSolucion())))); $this->addElement(new Zend_Form_Element_Text('nombre', array('label' => 'Nombre', 'required' => true, 'validators' => array(new Zend_Validate_Alnum(true)), 'maxlength' => '200', 'size' => '40'))); $this->addElement(new Zend_Form_Element_Image('imagenUpload')); $element = new Zend_Form_Element_File('imagen'); $element->setLabel('Upload an image:')->setDestination(APPLICATION_PATH . '/../public/dinamic/img/imagen-soluciones/'); $element->addValidator('Count', false, 1); $element->addValidator('Size', false, 102400); $element->addValidator('Extension', false, 'jpg,png,gif'); $this->addElement($element); $this->addElement(new Zend_Form_Element_Radio('flagActivo', array('label' => 'Activar', 'value' => '1', 'multioptions' => array('1' => 'Activo', '0' => 'Desactivo')))); $this->addElement(new Zend_Form_Element_Textarea('descripcioCorta', array('label' => 'Descripcion Corta', 'required' => true, 'rows' => '10'))); $this->addElement(new Zend_Form_Element_Textarea('descripcioLarga', array('label' => 'Descripcion Larga', 'required' => true))); $this->addElement(new Zend_Form_Element_Submit('Enviar', array('attribs' => array('class' => 'submit-button')))); }
public function init() { $this->setAttrib('enctype', 'multipart/form-data'); $this->setMethod('post'); $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE); $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER); $file = new Zend_Form_Element_File('Image'); $file->setLabel('Choose a picture:'); $file->addValidator('Count', false, 1); $file->addValidator('Size', false, array('max' => '1MB')); $file->setMaxFileSize(2048 * 1024); $file->addValidator('Extension', false, 'jpg,png,gif'); $file->setRequired(false); $file->setOptions(array('ignoreNoFile' => true)); $this->addElement($file, 'Image'); $this->addElement('submit', 'submit', array('label' => 'Submit!', 'class' => 'btn primary')); $this->addElement('submit', 'delete', array('label' => 'Delete current', 'class' => 'btn danger')); $this->setAttrib('class', 'form-stacked'); $this->addElement(Ml_Model_MagicCookies::formElement()); }
/** * Initialization form */ public function init() { parent::init(); //---------------- Форма ---------------- // Указываем action формы $urlAction = $this->getUrl('images', 'blogmanager'); $this->setAction($urlAction); //Зададим метод передачи данных $this->setMethod('post'); // Зададим тип передачи данных на сервер $this->setAttrib('enctype', 'multypart/form-data'); // Задаем атрибут class для формы $this->setAttrib('class', 'myfrm'); $this->setAttrib('id', 'blogpostimage-form'); //--------- Элемент Hidden -----------------// //Добавим скрытый элемент для перенаправления входа пользователя // $elId = new Zend_Form_Element_Hidden('id'); // $this->addElement($elId); // // if ($this->post_id) { // $this->setDefault('id', $this->post_id); // } //--------- Элемент Файл -----------------// $elFile = new Zend_Form_Element_File('image'); $elFile->setLabel('Выбрать файл с локального компьютера'); $path = Default_Model_DbTable_BlogPostImage::GetUploadPath(); $elFile->setDestination($path); //Будем грузить только один файл $elFile->addValidator('Count', false, 1); //Будем грузить файл размером - 1Мб $elFile->addValidator('Size', false, 1024000); //Будем грузить файл типа: JPEG, PNG, GIF $elFile->addValidator('Extension', false, 'jpg,png,gif'); //$elFile->setDecorators(array('ViewHelper')); $this->addElement($elFile); //--------- Кнопка submit -----------------// //Добавим кнопку $this->addElement('submit', 'upload', array('ignore' => true, 'label' => 'Загрузить изображение')); $this->getElement('upload')->setAttrib('class', 'btn btn-primary'); $this->getElement('upload')->setDecorators(array('ViewHelper')); }
public function init() { $template = 'nke/template'; $file = new Zend_Form_Element_File('template'); $file->setLabel('Télécharger un template :')->setDestination(APPLICATION_PATH . '/../var/upload' . $template); // ensure only 1 file $file->addValidator('Count', false, 1); $this->addElement($file); $envoyer = new Zend_Form_Element_Submit('envoyer'); $envoyer->setAttrib('id', 'boutonenvoyer'); $this->addElement($envoyer); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->addPrefixPath('Application_Form_Decorator', APPLICATION_PATH . '/forms/decorators/', 'decorator'); $this->addElement('text', 'name', array('label' => 'Name:', 'attribs' => array('maxlength' => 256, 'size' => 30), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 256))), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'name-element')), 'RequiredLabel'))); $this->addElement('text', 'country', array('label' => 'Country:', 'attribs' => array('maxlength' => 256, 'size' => 30), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 256))), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'country-element')), 'RequiredLabel'))); $this->addElement('text', 'town', array('label' => 'Town:', 'attribs' => array('maxlength' => 256, 'size' => 30), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 256))), 'decorators' => array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'dd', 'id' => 'town-element')), 'RequiredLabel'))); $this->addElement('text', 'link', array('label' => 'Link:', 'attribs' => array('maxlength' => 256, 'size' => 30), 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 256))))); $this->addElement('hidden', 'useExisting', array('required' => true, 'value' => 0, 'decorators' => array('ViewHelper'))); $element = new Zend_Form_Element_File('filename'); $element->setValueDisabled(true); $element->setRequired(true); $element->setLabel('Upload an image:'); $element->addValidator('Count', false, 1); $element->addValidator('Size', false, 9000000); $element->addValidator('Extension', false, 'jpg,png,gif'); $this->addElement($element, 'filename'); $this->addElement('submit', 'submit', array('label' => 'Submit', 'Description' => 'Fields marked with an asterisk (*) are required', 'ignore' => true, 'decorators' => array('ViewHelper', 'Description', array('HtmlTag', array('tag' => 'dd', 'id' => 'submit-element')), array('Label', array('tag' => 'dt', 'style' => 'display:none'))))); $this->addElement('hidden', 'id', array('ignore' => false, 'decorators' => array('ViewHelper'))); }
public function init() { $user = Zend_Auth::getInstance()->getIdentity(); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email')->setRequired(true)->addValidator('EmailAddress')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->addErrorMessage('Email address not valid'); $password = new Zend_Form_Element_Password('password'); $password->setLabel('Password')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setAttrib('autocomplete', 'off')->setRequired(true); $name = new Zend_Form_Element_Text('first_name'); $name->setLabel('First name')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setRequired(true); $lastname = new Zend_Form_Element_Text('last_name'); $lastname->setLabel('Last name')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setRequired(true); $role_name = new Zend_Form_Element_Select('role_id'); $role_name->setLabel('Account type')->setRequired(true)->setRegisterInArrayValidator(false); $role_name->setAttrib("class", "select2")->setAttrib("style", "width:200px"); $roles_table = new Admin_Model_Roles(); foreach ($roles_table->getAll() as $v) { $role_name->addMultiOption($v->id, $v->name); } $img = new Zend_Form_Element_File('image'); $img->setDestination(WEB_PATH . Zend_Registry::get('upload_profile_img_path')); $img->addValidator('Count', false, 1); $img->addValidator('Extension', false, 'jpeg,jpg,png,gif'); if ($img->getFileName()) { $new_name = md5(rand(1000, 10000) . time() . $img->getFileName()) . "." . preg_replace('/^.*\\.([^.]+)$/D', '$1', $img->getFileName()); $img->addFilter('Rename', $new_name); } $img->setLabel('Image'); $is_active = new Zend_Form_Element_Checkbox("is_active"); $is_active->setLabel('Active')->setAttrib("class", "icheckbox_square"); $cancel = new Zend_Form_Element_Button('cancel'); $cancel->setLabel('Cancel'); $cancel->setAttrib('class', 'btn btn-gold')->setAttrib('style', 'color:black'); $cancel->setAttrib("onClick", "window.location = window.location.origin+'/admin/admin-users/'"); $submit = new Zend_Form_Element_Submit('save'); $submit->setAttrib('class', 'btn btn-primary'); $submit->setLabel('Confirm'); $this->setAction('')->setMethod('post')->addElement($email)->addElement($password)->addElement($name)->addElement($lastname)->addElement($role_name)->addElement($img)->addElement($is_active)->addElement($cancel)->addElement($submit); }
public function init() { $this->setAction('')->setMethod('post'); $filename = time() . rand(1000, 9999); $ava = new Zend_Form_Element_File('ava'); $ava->setAttrib('width', 120); $ava->setLabel('Upload avatar (75x75 px)')->setDestination('avatars'); $ava->addFilter('Rename', sprintf('ava%s.jpg', $filename, true)); $ava->addValidator('Size', false, '204800')->addValidator('Extension', false, 'jpg,png,gif')->addValidator('ImageSize', false, array('minwidth' => 1, 'minheight' => 1, 'maxwidth' => 75, 'maxheight' => 75)); $submit = new Zend_Form_Element_Submit('uploadavatar'); $submit->setLabel("Upload"); $this->addElements(array($ava, $submit)); return $this; }
public function init() { $this->setName('photo_gallery'); $this->setMethod('Post'); $this->setAttrib('enctype', 'multipart/form-data'); $photo_name = new Zend_Form_Element_File('photo_name'); $photo_name->addValidator('Count', false, 1)->addValidator('FilesSize', false, array('min' => '10kB', 'max' => '3MB'))->setErrorMessages(array("Upload an image"))->addValidator('Extension', false, 'jpg,png,gif'); // only JPEG, PNG, and GIFs $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('photo_name')); $this->addElements(array($photo_name, $submit)); }