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 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->setAttrib('enctype', 'multipart/form-data'); $renameResize = new Zend_Form_Element_File('renameResize'); $renameResize->setDestination('../upload'); $renameResize->setLabel('Rename before resize'); $renameResize->addFilter('Rename', 'rename-resize'); $renameResize->addFilter(new Skoch_Filter_File_Resize(array('width' => 200, 'height' => 300, 'keepRatio' => true))); $this->addElement($renameResize); $resizeRename = new Zend_Form_Element_File('resizeRename'); $resizeRename->setDestination('../upload'); $resizeRename->setLabel('Resize before rename'); $resizeRename->addFilter(new Skoch_Filter_File_Resize(array('width' => 200, 'height' => 300, 'keepRatio' => true))); $resizeRename->addFilter('Rename', 'resize-rename'); $this->addElement($resizeRename); $multiResize = new Zend_Form_Element_File('multiResize'); $multiResize->setDestination('../upload'); $multiResize->setLabel('Multiple resizes'); $filterChain = new Zend_Filter(); // Create one big image with at most 600x300 pixel $filterChain->appendFilter(new Skoch_Filter_File_Resize(array('width' => 600, 'height' => 300, 'keepRatio' => true))); // Create a medium image with at most 500x200 pixels $filterChain->appendFilter(new Skoch_Filter_File_Resize(array('directory' => '../upload/medium', 'width' => 500, 'height' => 200, 'keepRatio' => true))); $multiResize->addFilter('Rename', 'multi-resize'); $multiResize->addFilter($filterChain); $this->addElement($multiResize); $renameCrop = new Zend_Form_Element_File('renameCrop'); $renameCrop->setDestination('../upload'); $renameCrop->setLabel('Rename before crop'); $renameCrop->addFilter('Rename', 'rename-crop'); $renameCrop->addFilter(new Skoch_Filter_File_Resize(array('width' => 20, 'height' => 30, 'cropToFit' => true, 'keepRatio' => true))); $this->addElement($renameCrop); $submit = new Zend_Form_Element_Submit('submit'); $this->addElement($submit); }
/** * Add appropriate validators, filters, and hidden elements for a file * upload element. * * @param Zend_Form_Element_File $element */ private function _processFileElement($element) { $element->setDestination(Zend_Registry::get('storage')->getTempDir()); $options = $this->getThemeOptions(); $fileName = @$options[$element->getName()]; if ($fileName) { $storage = Zend_Registry::get('storage'); $fileUri = $storage->getUri($storage->getPathByType($fileName, 'theme_uploads')); } else { $fileUri = null; } // Add extension/mimetype filtering. if (get_option(File::DISABLE_DEFAULT_VALIDATION_OPTION) != '1') { $element->addValidator(new Omeka_Validate_File_Extension(self::$allowedExtensions)); $element->addValidator(new Omeka_Validate_File_MimeType(self::$allowedMimeTypes)); $element->addValidator(new Zend_Validate_File_Size(array('max' => self::MAX_UPLOAD_SIZE))); } // Make sure the file was uploaded before adding the Rename filter to the element if ($element->isUploaded()) { $this->_addFileRenameFilter($element); } // add a hidden field to store whether already exists $hiddenElement = new Zend_Form_Element_Hidden(self::THEME_FILE_HIDDEN_FIELD_NAME_PREFIX . $element->getName()); $hiddenElement->setValue($fileUri); $hiddenElement->setDecorators(array('ViewHelper', 'Errors')); $hiddenElement->setIgnore(true); $this->addElement($hiddenElement); }
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;"))))); } }
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() { $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($categoryId) { global $mySession; $db = new Db(); $CategoryName = ""; $cattitle = ""; $catdesc = ""; $catimage = ""; $rssurl = ""; if ($categoryId != "") { //category_id, category_name, perent_id, cat_position, cat_title, cat_desc, cat_image, category_status, created_by, created_date $PageData = $db->runQuery("select * from " . CATEGORIES . " where category_id='" . $categoryId . "'"); $CategoryName = $PageData[0]['category_name']; $catposition = $PageData[0]['cat_position']; $cattitle = $PageData[0]['cat_title']; $catdesc = $PageData[0]['cat_desc']; $catimage = $PageData[0]['cat_image']; $rssurl = $PageData[0]['rss_url']; } $cat_position = new Zend_Form_Element_Hidden('cat_position'); $cat_position->setValue($catposition); $cat_image_file = new Zend_Form_Element_Hidden('cat_image_file'); $cat_image_file->setValue($catimage); $cat_desc = new Zend_Form_Element_Textarea('cat_desc'); $cat_desc->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Category Title is required.'))->setAttrib("style", "width:350px;height:150px")->setValue($catdesc); $category_name = new Zend_Form_Element_Text('category_name'); $category_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Category Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:350px;")->setValue($CategoryName); $cat_title = new Zend_Form_Element_Text('cat_title'); $cat_title->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Category Title is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:350px;")->setValue($cattitle); $rss_url = new Zend_Form_Element_Text('rss_url'); $rss_url->setAttrib("class", "textInput")->setAttrib("style", "width:350px;")->setValue($rssurl); $photo_path = new Zend_Form_Element_File('photo_path'); $photo_path->setDestination(SITE_ROOT . 'images/category/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->setRequired(false)->addDecorator('Errors', array('class' => 'error')); $this->addElements(array($category_name, $cat_title, $cat_desc, $cat_image_file, $rss_url, $cat_position, $photo_path)); }
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->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() { global $mySession; $db = new Db(); $image = new Zend_Form_Element_File('image'); $image->setDestination(SITE_ROOT . 'images/adminpostimg/')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Please select a photo.'))->addValidator('Extension', false, 'jpg,jpeg,png,gif')->setAttrib("class", "textbox")->addDecorator('Errors', array('class' => 'error')); $this->addElement($image); }
public function init() { // projeto_id $projeto_id = new Zend_Form_Element_Select("projeto_id"); $projeto_id->setLabel("Projeto: "); $projeto_id->setAttribs(array('class' => 'form-control')); $projeto_id->setMultiOptions($this->getProjetos()); // cliente_id $cliente_id = new Zend_Form_Element_Select("cliente_id"); $cliente_id->setLabel("Cliente: "); $cliente_id->setAttribs(array('class' => 'form-control')); $cliente_id->setRequired(false); $cliente_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $cliente_id->setMultiOptions($this->getClientes()); // faturamento_tipo $faturamento_tipo = new Zend_Form_Element_Select("faturamento_tipo"); $faturamento_tipo->setLabel("Tipo: "); $faturamento_tipo->setAttribs(array('class' => 'form-control')); $faturamento_tipo->setRequired(false); $faturamento_tipo->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $faturamento_tipo->setMultiOptions(array(1 => 'Boleto', 2 => 'Transferência')); // faturamento_valor $faturamento_valor = new Zend_Form_Element_Text("faturamento_valor"); $faturamento_valor->setLabel("Valor: "); $faturamento_valor->setAttribs(array('class' => 'form-control')); //$faturamento_valor->setRequired(); $faturamento_valor->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); // faturamento_descricao $faturamento_descricao = new Zend_Form_Element_Text("faturamento_descricao"); $faturamento_descricao->setLabel("Descrição: "); $faturamento_descricao->setAttribs(array('class' => 'form-control')); $faturamento_descricao->setRequired(); $faturamento_descricao->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); // faturamento_nosso_numero $faturamento_nosso_numero = new Zend_Form_Element_Text("faturamento_nosso_numero"); $faturamento_nosso_numero->setLabel("Nosso Nº: "); $faturamento_nosso_numero->setAttribs(array('class' => 'form-control')); //$faturamento_nosso_numero->setRequired(); $faturamento_nosso_numero->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); // faturamento_vencimento $faturamento_vencimento = new Zend_Form_Element_Text("faturamento_vencimento"); $faturamento_vencimento->setLabel("Vencimento: "); $faturamento_vencimento->setAttribs(array('class' => 'form-control')); $faturamento_vencimento->setRequired(); $faturamento_vencimento->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); // faturamento_nota_fiscal $faturamento_nota_fiscal = new Zend_Form_Element_File("faturamento_nota_fiscal"); $faturamento_nota_fiscal->setLabel("Nota Fiscal:"); $faturamento_nota_fiscal->addDecorators(App_Forms_Decorators::$ElementDecoratorFile); $faturamento_nota_fiscal->setAttribs(array('class' => 'filestyle', 'data-buttonText' => 'Selecione a Nota Fiscal', 'data-iconName' => 'fa fa-file')); //$faturamento_nota_fiscal->setRequired(); $faturamento_nota_fiscal->setDestination(Zend_Registry::get('config')->notafiscal->filepath); $faturamento_nota_fiscal->addValidators(array(array('Extension', false, 'pdf'))); $this->addElements(array($projeto_id, $cliente_id, $faturamento_tipo, $faturamento_vencimento, $faturamento_valor, $faturamento_nosso_numero, $faturamento_descricao, $faturamento_nota_fiscal)); parent::init(); }
public function init() { $this->setName('gallery'); $this->setIsArray(true); $this->id = new Zend_Form_Element_Hidden('id'); $this->source = new Zend_Form_Element_Text('source'); $this->caption = new Zend_Form_Element_Textarea('caption'); $this->caption_en = new Zend_Form_Element_Textarea('caption_en'); $this->image = new Zend_Form_Element_File('image'); $this->submit = new Zend_Form_Element_Submit('submit'); $this->source->setAttribs(array('class' => 'span6')); $this->caption->setRequired(true)->setAttribs(array('class' => 'span6', 'rows' => 3, 'style' => 'height:auto;font-size: 16px;font-weight:normal;font-family:Helvetica;padding:5px 10px')); $this->caption_en->setRequired(true)->setAttribs(array('class' => 'span6', 'rows' => '3', 'style' => 'height:auto;font-size: 16px;font-weight:normal;font-family:Helvetica;padding:5px 10px')); $this->image->setDestination(UPLOAD_FOLDER . 'gallery')->addValidator(new Zend_Validate_File_Extension('jpg, png')); $this->submit->setLabel('Simpan'); $this->submit->setAttrib('class', 'btn btn-success'); $this->addElements(array($this->id, $this->source, $this->caption, $this->caption_en, $this->image, $this->submit)); $this->setElementDecorators(array('ViewHelper', 'Errors'), array('image'), false); $this->image->setDecorators(array('file')); }
public function init() { global $mySession; $photo_title = new Zend_Form_Element_Text('photo_title'); $photo_title->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Photo title is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput"); $photo_path = new Zend_Form_Element_File('photo_path'); $photo_path->setDestination(SITE_ROOT . 'images/floorplan/')->addValidator('Extension', false, 'jpg,pdf')->setAttrib("class", "mws-textinput")->addDecorator('Errors', array('class' => 'error')); $step = new Zend_Form_Element_Hidden('step'); $step->setValue("5"); $this->addElements(array($photo_path, $step)); }
public function init() { // proposta_numero $proposta_numero = new Zend_Form_Element_Text("proposta_numero"); $proposta_numero->setLabel("Número: "); $proposta_numero->setAttribs(array('class' => 'form-control')); // proposta_tipo_id $proposta_tipo_id = new Zend_Form_Element_Select("proposta_tipo_id"); $proposta_tipo_id->setLabel("Tipo Proposta: "); $proposta_tipo_id->setAttribs(array('class' => 'form-control')); $proposta_tipo_id->setRequired(); $proposta_tipo_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $proposta_tipo_id->setMultiOptions($this->getPropostaTipo()); // cliente_id $cliente_id = new Zend_Form_Element_Select("cliente_id"); $cliente_id->setLabel("Cliente: "); $cliente_id->setAttribs(array('class' => 'form-control')); $cliente_id->setRequired(); $cliente_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $cliente_id->setMultiOptions($this->getClientes()); // tipo_servico_id $tipo_servico_id = new Zend_Form_Element_Select("tipo_servico_id"); $tipo_servico_id->setLabel("Tipo de Serviço: "); $tipo_servico_id->setAttribs(array('class' => 'form-control')); $tipo_servico_id->setRequired(); $tipo_servico_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $tipo_servico_id->setMultiOptions($this->getTipoServicos()); // proposta_horas $proposta_horas = new Zend_Form_Element_Text("proposta_horas"); $proposta_horas->setLabel("Horas: "); $proposta_horas->setAttribs(array('class' => 'form-control')); // proposta_valor $proposta_valor = new Zend_Form_Element_Text("proposta_valor"); $proposta_valor->setLabel("Valor: "); $proposta_valor->setAttribs(array('class' => 'form-control')); // proposta_data $proposta_data = new Zend_Form_Element_Text("proposta_data"); $proposta_data->setLabel("Data: "); $proposta_data->setAttribs(array('class' => 'form-control')); // proposta_vencimento $proposta_vencimento = new Zend_Form_Element_Text("proposta_vencimento"); $proposta_vencimento->setLabel("Vencimento: "); $proposta_vencimento->setAttribs(array('class' => 'form-control')); // proposta_documento $proposta_documento = new Zend_Form_Element_File("proposta_documento"); $proposta_documento->setLabel("Proposta:"); $proposta_documento->addDecorators(App_Forms_Decorators::$ElementDecoratorFile); $proposta_documento->setAttribs(array('class' => 'filestyle', 'data-buttonText' => 'Selecione o PDF', 'data-iconName' => 'fa fa-file')); //$proposta_documento->setRequired(); $proposta_documento->setDestination(Zend_Registry::get('config')->proposta->filepath); $proposta_documento->addValidators(array(array('Extension', false, 'pdf'))); $this->addElements(array($proposta_numero, $cliente_id, $proposta_tipo_id, $tipo_servico_id, $proposta_horas, $proposta_valor, $proposta_data, $proposta_vencimento, $proposta_documento)); parent::init(); }
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'); }
public function init() { $this->setName('partner'); $this->setIsArray(true); $this->id = new Zend_Form_Element_Hidden('id'); $this->language_id = new Zend_Form_Element_HIdden('language_id'); $this->name = new Zend_Form_Element_Text('name'); $this->logo = new Zend_Form_Element_File('logo'); $this->website = new Zend_Form_Element_Text('website'); $this->description = new Zend_Form_Element_Textarea('description'); $this->submit = new Zend_Form_Element_Submit('submit'); $this->name->setRequired(true)->setAttribs(array('class' => 'span6', 'placeholder' => 'Tulis nama partner disini...', 'style' => 'font-size: 16px;font-weight:normal;font-family:Helvetica;padding:5px 10px')); $this->website->addValidator(new Budpar_Form_Validator_Url())->setAttribs(array('class' => 'span11', 'placeholder' => 'http://www.example.com')); $this->logo->setDestination(UPLOAD_FOLDER . 'partners-logo')->addValidator(new Zend_Validate_File_Extension('jpg, png')); $this->description->setRequired(true)->setAttribs(array('cols' => 100, 'rows' => 20)); $this->submit->setLabel('Simpan'); $this->submit->setAttrib('class', 'btn btn-success'); $this->addElements(array($this->id, $this->language_id, $this->name, $this->logo, $this->website, $this->description, $this->submit)); $this->setElementDecorators(array('ViewHelper', 'Errors'), array('logo'), false); $this->logo->setDecorators(array('file')); }
public function init() { $this->setAttrib('id', 'pipelinePropertyValueAdd')->setAction('/admin/pipeline-property-value/add')->setMethod('post')->setEnctype(Zend_Form::ENCTYPE_MULTIPART); $this->addElement('hidden', 'pipelineId'); $this->addElement('select', 'propertyId', array('label' => 'Свойство', 'placeholder' => 'Свойство', 'required' => true, 'multiOptions' => $this->_getPropertyArray())); $this->addElement('text', 'value', array('label' => 'Значение', 'placeholder' => 'Значение', 'disabled' => 'disabled')); $this->addElement('text', 'valueText', array('label' => 'Значение', 'placeholder' => 'Значение', 'required' => true)); $this->addElement('textarea', 'valueTextArea', array('label' => 'Значение', 'placeholder' => 'Значение', 'rows' => '4', 'required' => true)); $file = new Zend_Form_Element_File('valueLoadFile'); $file->setDestination(APPLICATION_ROOT . '/upload/pipeline/items/')->addValidator('Size', false, 1024000)->addValidator('Extension', false, 'jpg,png,gif,pdf')->setLabel('Значение'); $this->addElement($file); }
public function init() { global $mySession; $db = new Db(); $excelfile = new Zend_Form_Element_File('excelfile'); $excelfile->setDestination(SITE_ROOT . 'test/')->addDecorator('Errors', array('class' => 'error')); $this->addElement($excelfile); //echo SITE_ROOT.'upload/'; $zipfile = new Zend_Form_Element_File('zipfile'); $zipfile->setDestination(SITE_ROOT . 'test/')->addDecorator('Errors', array('class' => 'error')); $this->addElement($zipfile); }
public function init() { // Задаём имя форме $this->setName('documentation'); $description = new Zend_Form_Element_Text('description', array('class' => 'form-control')); $description->setRequired(true)->setAttrib('placeholder', 'Введите название:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('regex', true, array("/^[A-Za-zА-Яа-я1-90 \\.\\-\\А\\П\\Н]{3,20}\$/i", 'messages' => $settings['messages']['error']))->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $settings['messages']['empty'])))->removeDecorator('label')->removeDecorator('element')->removeDecorator('errors'); $validator = new Zend_Validate_File_Upload(); $validator->setMessages(array('fileUploadErrorNoFile' => 'Файл не выбран!')); $file = new Zend_Form_Element_File('file'); $file->setDestination(DATA_PATH . '/public/data/')->setRequired(true)->addValidator($validator); // Создаём элемент формы Submit c именем = submit $submit = new Zend_Form_Element_Submit('submit', array('class' => 'btn btn-default', 'id' => 'data_submit')); $this->addElements(array($description, $submit, $file)); }
public function getFileElement() { $element = $this->getElement($this->_fileElementName); if (!$element) { $element = new Zend_Form_Element_File($this->_fileElementName); $element->setDestination(APPLICATION_PATH . '/public/temporary/'); //->setMultiFile(2) //->addValidator('Count', false, 1) //->addValidator('Size', false, 102400) //->addValidator('Extension', false, 'jpg,png,gif,jpeg'); $this->addElement($element, $this->_fileElementName); } return $element; }
public function init($blogid) { //echo $blogid; die; global $mySession; $db = new Db(); $image_value = ""; $blogtitle_value = ""; $blogdesc_value = ""; $status_value = ""; $blog_value = ""; $old_image_value = ""; if ($blogid != "") { $Data = $db->runQuery("select * from " . BLOGPOST . " where blog_id='" . $blogid . "'"); //$image_value=$Data[0]['post_image']; $blogtitle_value = $Data[0]['blog_title']; $blogdesc_value = $Data[0]['blog_desc']; $image_value = $Data[0]['blog_image']; $status_value = $Data[0]['blog_status']; $old_image_value = $Data[0]['blog_image']; } $old_image = new Zend_Form_Element_Hidden('old_image'); $old_image->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setValue($old_image_value); $this->addElement($old_image); $image = new Zend_Form_Element_File('image'); $image->setDestination(SITE_ROOT . 'images/blogimg/'); if ($blogid == "") { $image->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Please select a photo.')); } $image->addValidator('Extension', false, 'jpg,jpeg,png,gif')->setAttrib("class", "textbox")->addDecorator('Errors', array('class' => 'error'))->setValue($image_value); $this->addElement($image); $blogtitle = new Zend_Form_Element_Text('blogtitle'); $blogtitle->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:165px;")->setValue($blogtitle_value); $this->addElement($blogtitle); $blog_description = new Zend_Form_Element_Textarea('blog_description'); $blog_description->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Please enter this field.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:170px; height:60px;")->setValue($blogdesc_value); $this->addElement($blog_description); //echo "dfs"; die; $StatusArr = array(); $StatusArr[0]['key'] = "1"; $StatusArr[0]['value'] = "Active"; $StatusArr[1]['key'] = "0"; $StatusArr[1]['value'] = "Inactive"; $blog_status = new Zend_Form_Element_Select('blog_status'); $blog_status->addMultiOptions($StatusArr)->setAttrib("class", "textInput")->setValue($status_value); $this->addElement($blog_status); }
public function init() { // profissional_beleza_nome $profissional_beleza_nome = new Zend_Form_Element_Text("profissional_beleza_nome"); $profissional_beleza_nome->setLabel("Nome: "); $profissional_beleza_nome->setAttribs(array('class' => 'form-control')); $profissional_beleza_nome->setRequired(); $profissional_beleza_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // profissional_beleza_email $profissional_beleza_email = new Zend_Form_Element_Text("profissional_beleza_email"); $profissional_beleza_email->setLabel("E-mail: "); $profissional_beleza_email->setValidators(array('EmailAddress')); $profissional_beleza_email->addValidator(new App_Validate_ProfissionalBeleza()); $profissional_beleza_email->setAttribs(array('class' => 'form-control')); $profissional_beleza_email->setRequired(); $profissional_beleza_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators); /** * profisional_beleza_sexo */ $profissional_beleza_sexo = new Zend_Form_Element_Radio("profissional_beleza_sexo"); $profissional_beleza_sexo->setLabel("Sexo:"); $profissional_beleza_sexo->setRequired(); $profissional_beleza_sexo->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $profissional_beleza_sexo->setMultiOptions(array('M' => ' Masculino', 'F' => ' Feminino')); // profissional_beleza_avatar $profissional_beleza_avatar = new Zend_Form_Element_File("profissional_beleza_avatar"); $profissional_beleza_avatar->setLabel(" \n Foto: \n "); $profissional_beleza_avatar->addDecorators(App_Forms_Decorators::$ElementDecoratorFile); $profissional_beleza_avatar->setAttribs(array('class' => 'filestyle', 'data-buttonText' => 'Selecione a foto', 'data-iconName' => 'fa fa-user')); $profissional_beleza_avatar->setRequired(); $profissional_beleza_avatar->setDestination(Zend_Registry::get('config')->profissional->avatar->path); $profissional_beleza_avatar->addValidators(array(array('Extension', false, 'jpg,jpeg,png'))); $profissional_beleza_avatar->addFilter(new Skoch_Filter_File_Resize(array('width' => 160, 'keepRatio' => true))); // especialidade_id $especialidade_id = new Zend_Form_Element_MultiCheckbox("especialidade_id"); $especialidade_id->setLabel("Selecione as especialidades: "); $especialidade_id->setAttribs(array('class' => '')); $especialidade_id->setRequired(); $especialidade_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); $especialidade_id->setSeparator(' '); $especialidade_id->setMultiOptions($this->getEspecialidades()); // addElements $this->addElements(array($profissional_beleza_nome, $profissional_beleza_email, $profissional_beleza_sexo, $profissional_beleza_avatar, $especialidade_id)); parent::init(); }
public function init() { global $mySession; $db = new Db(); //echo SITE_ROOT.'images/adimage/'; //echo "select * from ".ADMINISTRATOR." where admin_id='1'"; $Managead = $db->runQuery("select * from " . ADMINISTRATOR . " where admin_id='1'"); $ad_url_value = $Managead[0]['ad_url']; $old_advertise_image_value = $Managead[0]['ad_image']; $advertise_image = new Zend_Form_Element_File('advertise_image'); $advertise_image->setDestination(SITE_ROOT . 'images/adimage/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'error')); $this->addElement($advertise_image); $old_advertise_image = new Zend_Form_Element_Hidden('old_advertise_image'); $old_advertise_image->setValue($old_advertise_image_value); $this->addElement($old_advertise_image); $ad_url = new Zend_Form_Element_Text('ad_url'); $ad_url->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Advertise url is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setValue($ad_url_value); $this->addElement($ad_url); }
public function init() { global $mySession; $db = new Db(); $default_business_image = new Zend_Form_Element_File('default_business_image'); $default_business_image->setDestination(SITE_ROOT . 'images/businesses/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg')); $this->addElement($default_business_image); $default_event_image = new Zend_Form_Element_File('default_event_image'); $default_event_image->setDestination(SITE_ROOT . 'images/events/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg')); $this->addElement($default_event_image); $default_male_image = new Zend_Form_Element_File('default_male_image'); $default_male_image->setDestination(SITE_ROOT . 'images/profileimgs/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg')); $this->addElement($default_male_image); $default_female_image = new Zend_Form_Element_File('default_female_image'); $default_female_image->setDestination(SITE_ROOT . 'images/profileimgs/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg')); $this->addElement($default_female_image); $default_both_image = new Zend_Form_Element_File('default_both_image'); $default_both_image->setDestination(SITE_ROOT . 'images/profileimgs/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'errmsg')); $this->addElement($default_both_image); }
/** * 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() { $form = new Zend_Form("form"); $form->setMethod('post'); $title = new Zend_Form_Element_Text("title"); $title->setLabel("Title:"); $title->setAttrib("placeholder", "Title"); $title->setAttrib("class", "form-control"); $title->setRequired(); $picture = new Zend_Form_Element_File("picture"); $picture->setLabel("Picture:"); $picture->setDestination('/var/www/html/RNR/public/images/category'); $picture->setRequired(); $id = new Zend_Form_Element_Hidden("id"); $submit = new Zend_Form_Element_Submit("Submit"); $submit->setLabel("Save"); $submit->setAttrib("class", "btn btn-primary"); $rest = new Zend_Form_Element_Reset('Reset'); $rest->setAttrib("class", "btn btn-info"); $this->addElements(array($title, $picture, $submit, $rest, $id)); }
public function init($categoryId) { global $mySession; $db = new Db(); $CategoryName = ""; $old_cat_image_value = ""; if ($categoryId != "") { $PageData = $db->runQuery("select * from " . CATEGORY . " where cat_id='" . $categoryId . "'"); $CategoryName = $PageData[0]['cat_name']; $old_cat_image_value = $PageData[0]['cat_image']; } $cat_name = new Zend_Form_Element_Text('cat_name'); $cat_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Category Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:350px;")->setValue($CategoryName); $cat_image = new Zend_Form_Element_File('cat_image'); $cat_image->setDestination(SITE_ROOT . 'images/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'error')); $this->addElement($cat_image); $old_cat_image = new Zend_Form_Element_Hidden('old_cat_image'); $old_cat_image->setValue($old_cat_image_value); $this->addElement($old_cat_image); $this->addElements(array($cat_name, $cat_image, $old_cat_image)); }
public function init($subcateId) { global $mySession; $db = new Db(); $SubCategoryName = ""; $old_subcat_image_value = ""; $category_value = ""; if ($subcateId != "") { //echo "select * from ".SUBCATE." where subcate_id='".$subcateId."'";exit(); $PageData = $db->runQuery("select * from " . SUBCATE . " where subcate_id='" . $subcateId . "'"); $SubCategoryName = $PageData[0]['subcate_name']; $old_subcat_image_value = $PageData[0]['subcate_img_path']; $category_value = $PageData[0]['cat_id']; } $CateArr = array(); $CateArr[0]['key'] = ""; $CateArr[0]['value'] = "- - Categories - -"; $CateData = $db->runQuery("select * from " . SERVICE_CATEGORIES . " order by category_name"); if ($CateData != "" and count($CateData) > 0) { $i = 1; foreach ($CateData as $key => $CateValue) { $CateArr[$i]['key'] = $CateValue['cat_id']; $CateArr[$i]['value'] = $CateValue['category_name']; $i++; } } $category = new Zend_Form_Element_Select('category'); $category->setRequired(true)->addMultiOptions($CateArr)->addValidator('NotEmpty', true, array('messages' => 'Category is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("style", "width:250px;")->setValue($category_value); $this->addElement($category); $subcate_name = new Zend_Form_Element_Text('subcate_name'); $subcate_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Sub Category Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput")->setAttrib("style", "width:350px;")->setValue($SubCategoryName); $this->addElement($subcate_name); $subcate_image = new Zend_Form_Element_File('subcate_image'); $subcate_image->setDestination(SITE_ROOT . 'images/Subcate/')->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addDecorator('Errors', array('class' => 'error')); $this->addElement($subcate_image); $old_subcat_image = new Zend_Form_Element_Hidden('old_subcat_image'); $old_subcat_image->setValue($old_subcat_image_value); $this->addElement($old_subcat_image); // $this->addElements(array($subcate_name,$subcate_image,$old_subcat_image,)); }
public function init() { $this->setMethod("post"); $this->setAttrib("class", "form-horizontal"); $username = new Zend_Form_Element_Text("userName"); $username->setLabel("User Name:"); $username->setRequired(); $username->setAttrib("placeholder", "User name"); $username->setAttrib("class", "form-control"); $username->addFilter(new Zend_Filter_StripTags()); $email = new Zend_Form_Element_Text("email"); $email->setRequired()->setLabel("Email:")->addValidator(new Zend_Validate_EmailAddress())->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'user', 'field' => 'email'))); $email->setAttrib("placeholder", "Email"); $email->setAttrib("class", "form-control"); $password = new Zend_Form_Element_Password("password"); $password->setRequired()->setLabel("Password:"******"placeholder", "Password"); $password->setAttrib("class", "form-control"); $country = new Zend_Form_Element_Select('country'); $country->setMultiOptions(array('Egypt' => 'Egypt', 'Kuwait' => 'Kuwait', 'Canada' => 'Canada')); $country->setLabel("Country:"); $country->setAttrib("class", "form-control"); $gender = new Zend_Form_Element_Radio('gender'); $gender->setRequired(true)->setLabel("Gender:")->addMultiOptions(array('male' => 'Male', 'female' => 'Female'))->setSeparator(" "); $profilePicture = new Zend_Form_Element_File('profilePicture'); $profilePicture->setLabel("ProfilePicture:"); $profilePicture->setDestination('/var/www/html/RNR/public/images/user/profilePicture'); $signature = new Zend_Form_Element_File('signature'); $signature->setLabel("Signature:"); $signature->setDestination('/var/www/html/RNR/public/images/user/signature'); $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_Reset('Reset'); $rest->setAttrib("class", "btn btn-info"); $this->addElements(array($id, $username, $email, $password, $country, $gender, $profilePicture, $signature, $submit, $rest)); /* Form Elements & Other Definitions Here ... */ }