public function init() { /* Form Elements & Other Definitions Here ... */ $this->setMethod("POST"); $name = new Zend_Form_Element_Text("name"); $name->setRequired(); $name->setLabel("material name:"); $name->setAttrib("placeholder", "Enter material name"); $name->addValidator(new Zend_Validate_Alnum("true")); $name->setAttrib("class", "form-control"); $name->getDecorator("Label")->setOption("class", "control-label"); $name->getDecorator("Errors")->setOption("class", "alert alert-danger"); $name->getDecorator("Errors")->setOption("style", " list-style-type:none"); $path = new Zend_Form_Element_File('path'); $path->setLabel('Select File:'); $path->setRequired(); $path->setAttrib("class", "form-control"); $path->setAttrib("class", "file-loading"); $path->getDecorator("Label")->setOption("class", "control-label"); $path->getDecorator("Errors")->setOption("class", "alert alert-danger"); $path->getDecorator("Errors")->setOption("style", " list-style-type:none"); $course = new Zend_Form_Element_Select('cid'); $course->setLabel('Course Name:'); //$course ->setMultiOptions(array( '5'=>'a','6'=>'c')); $course->setRequired(true)->addValidator('NotEmpty', true); $course->setAttrib("class", "form-control"); $course->getDecorator("Label")->setOption("class", "control-label"); $course->getDecorator("Errors")->setOption("class", "alert alert-danger"); $course->getDecorator("Errors")->setOption("style", " list-style-type:none"); $type = new Zend_Form_Element_Select('tid'); $type->setLabel('Material Type:'); //$type->setMultiOptions(array( '1'=>'pdf','2'=>'ppt')); $type->setRequired(true)->addValidator('NotEmpty', true); $type->setAttrib("class", "form-control"); $type->getDecorator("Label")->setOption("class", "control-label"); $type->getDecorator("Errors")->setOption("class", "alert alert-danger"); $type->getDecorator("Errors")->setOption("style", " list-style-type:none"); $mdate = new Zend_Form_Element_Hidden("mdate"); $submit = new Zend_Form_Element_Submit("submit"); $submit->setAttrib("class", "btn btn-xl center-block"); //$submit->setAttrib("class", "btn"); $this->addElements(array($name, $path, $course, $type, $mdate, $submit)); }
public function init() { $this->setName('f3')->setAttrib('enctype', 'multipart/form-data')->setMethod('post')->setAttribs(array('onsubmit' => 'return kiem_tra()', 'name' => 'f3')); $baseUrl = Khcn_View_Helper_GetBaseUrl::getBaseUrl(); $file = new Zend_Form_Element_File('file'); $file->setLabel('Upload file')->setRequired(true)->setDescription('(*.xlsx, *.xls)<br/> Click <a href="' . $baseUrl . '/../application/templates/admin/files/bai_bao_khoa_hoc_import.xlsx">here</a> to download sample file.')->setDestination(BASE_PATH . '/upload/files/temp/')->addValidator(new Zend_Validate_File_Extension(array('xls', 'xlsx')))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('HtmlTag', array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'file')); $file->getDecorator('Description')->setOption('escape', false); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Lưu vào csdl')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span', 'class' => 'filter_btn_l'))))->setAttribs(array('class' => 'button')); $this->addElements(array($file, $submit)); $this->addDisplayGroup(array('submit'), 'import', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'td')), array('HtmlTag', array('tag' => 'tr', 'id' => 'import'))))); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'import_dt')), 'Form')); }
public function testDefaultDecoratorsContainDescription() { $element = new Zend_Form_Element_File('baz'); $decorators = $element->getDecorator('Description'); $this->assertTrue($decorators instanceof Zend_Form_Decorator_Description); }
/** * @group GH-247 */ public function testCallbackFunctionAtHtmlTag() { $this->assertEquals(array('callback' => array('Zend_Form_Element_File', 'resolveElementId')), $this->element->getDecorator('HtmlTag')->getOption('id')); }