当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form::setAttrib方法代码示例

本文整理汇总了PHP中Zend_Form::setAttrib方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::setAttrib方法的具体用法?PHP Zend_Form::setAttrib怎么用?PHP Zend_Form::setAttrib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form的用法示例。


在下文中一共展示了Zend_Form::setAttrib方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nodeForm

 /**
  * Hook for node form - if type is Filemanager Node, add extra fields
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeForm(Zend_Form &$form, &$arguments)
 {
     $item =& array_shift($arguments);
     if (!Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest() && $item->type == "filemanager_file") {
         // Add Filemanager fields
         $form->setAttrib('enctype', 'multipart/form-data');
         $file = new Zend_Form_Element_File('filemanager_file');
         $file->setLabel("Select file")->setDestination(ZfApplication::$_data_path . DIRECTORY_SEPARATOR . "files")->setRequired(false);
         $form->addElement($file);
         $fields[] = 'filemanager_file';
         if ($item->id > 0) {
             // Fetch Filemanager object
             $factory = new Filemanager_File_Factory();
             $file_item = $factory->find($item->id)->current();
             if ($file_item) {
                 $existing = new Zend_Form_Element_Image('filemanager_image');
                 if (substr($file_item->mimetype, 0, 5) == "image") {
                     $imageid = $file_item->nid;
                 } else {
                     $imageid = 0;
                 }
                 $urlOptions = array('module' => 'filemanager', 'controller' => 'file', 'action' => 'show', 'id' => $imageid);
                 $existing->setImage(Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, 'default'));
                 $fields[] = 'filemanager_image';
             }
         }
         $options = array('legend' => Zoo::_("File upload"));
         $form->addDisplayGroup($fields, 'filemanager_fileupload', $options);
     } else {
         // Add content node image selector
     }
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:38,代码来源:Node.php

示例2: removeAction

 public function removeAction()
 {
     $form = new Zend_Form();
     $form->setView(new Zend_View());
     $form->setMethod('post');
     $form->setAction('');
     $form->setAttrib('class', 'devel');
     $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name'));
     $handleOptions = explode(',', $this->getRequest()->getParam('handles'));
     $referenceOptions = explode(',', $this->getRequest()->getParam('references'));
     $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used'));
     $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper')));
     $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper')));
     $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper')));
     $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used')));
     $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions)));
     $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true));
     $submit = $form->createElement('submit', 'submit', array('label' => 'Submit'));
     $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit));
     if ($form->isValid($this->getRequest()->getParams())) {
         $localXmlWriter = Mage::getModel('devel/writer_localxml');
         $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue());
         $localXmlWriter->save();
         die('DONE. You need to reload to see changes!');
     } else {
         $this->loadLayout();
         $this->getLayout()->getUpdate()->load('devel_layout_wizard');
         $this->getLayout()->generateXml();
         $this->loadLayout();
         $this->getLayout()->getBlock('devel_wizard_form')->setForm($form);
         $this->renderLayout();
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:33,代码来源:LayoutController.php

示例3: __construct

 /**
  * Constructor requiring Zend_Form instance to be rendered
  * @param Zend_Form $form
  */
 public function __construct(Zend_Form $form, $form_id = null)
 {
     $this->form = $form;
     $this->form->setAttrib('class', 'form_view');
     if (!is_null($form_id)) {
         $this->form->setAttrib('id', $form_id);
     }
     // Zend_Translate could be an option but the scope is a situation
     // where allready other internationalisation systems exist
     $this->lang = new My_LanguagePack();
 }
开发者ID:TBeijen,项目名称:Zend_Form_Without_MVC,代码行数:15,代码来源:My_Form_Renderer_View.php

示例4: __construct

 /**
  * Constructor requiring Zend_Form instance to be rendered
  * @param Zend_Form $form
  */
 public function __construct(Zend_Form $form, $form_id = null)
 {
     // create view and specify doctype to have self-closing tags.
     $view = new Zend_View();
     $view->setBasePath(dirname(__FILE__));
     $view->doctype('XHTML1_TRANSITIONAL');
     $this->form = $form;
     $this->form->setView(new Zend_View());
     $this->form->setAttrib('class', 'form_dynamic');
     if (!is_null($form_id)) {
         $this->form->setAttrib('id', $form_id);
     }
 }
开发者ID:TBeijen,项目名称:Zend_Form_Dynamic,代码行数:17,代码来源:My_Form_Renderer_Hour.php

示例5: __construct

 /**
  * Constructor requiring Zend_Form instance to be rendered
  * @param Zend_Form $form
  */
 public function __construct(Zend_Form $form, $form_id = null)
 {
     // create view and specify doctype to have self-closing tags.
     $view = new Zend_View();
     $view->doctype('XHTML1_TRANSITIONAL');
     $this->form = $form;
     $this->form->setView(new Zend_View());
     $this->form->setAttrib('class', 'form_edit');
     if (!is_null($form_id)) {
         $this->form->setAttrib('id', $form_id);
     }
     // Zend_Translate could be an option but the scope is a situation
     // where allready other internationalisation systems exist
     $this->lang = new My_LanguagePack();
 }
开发者ID:TBeijen,项目名称:Zend_Form_Without_MVC,代码行数:19,代码来源:My_Form_Renderer_Edit.php

示例6: dojoHelperAction

 public function dojoHelperAction()
 {
     $this->_helper->layout()->setLayout('layouts/site-dojo');
     $this->view->dojo()->enable()->setDjConfigOption('parseOnLoad', true)->setDjConfigOption('locale', 'en-US')->setDjConfigOption('isDebug', true)->setLocalPath('scripts/dojo/1.6/dojo/dojo.js')->addStyleSheetModule('dijit.themes.soria');
     $form = new Zend_Form();
     $form->setAttrib('id', 'mainform');
     $form->setAttrib('class', 'siteInteraction');
     $form->setAction('test/zend-forms/login')->setMethod('post');
     Zend_Dojo::enableForm($form);
     $form->addElement('NumberTextBox', 'foo', array('type' => 'percent', 'value' => '0.1', 'label' => 'Percentage:'));
     $form->addElement('NumberTextBox', 'foodos', array('constraints' => array('min' => 0, 'max' => 15, 'places' => 0), 'required' => 'true', 'value' => '11', 'label' => 'Number text Box:', 'class' => ''));
     $form->addElement('button', 'btn', array('label' => 'SEND'));
     //$form->getElement('btn')->removeDecorator('DtDdWrapper');
     $this->view->form = $form;
 }
开发者ID:laiello,项目名称:zend-ifc-controller-action-configuration,代码行数:15,代码来源:FormsController.php

示例7: getUploadForm

 /**
  * @return Zend_Form
  */
 public function getUploadForm()
 {
     static $form;
     if (null === $form) {
         $form = new Zend_Form();
         $form->setAttrib('enctype', 'multipart/form-data')->addElement('file', 'xml', array('label' => _('File'), 'required' => true, 'validators' => array('NotEmpty' => array())));
         $statusOptions = ['label' => 'Status for imported concepts'];
         if ($this->getTenant()['enableStatusesSystem']) {
             $statusOptions['multiOptions'] = OpenSKOS_Concept_Status::statusesToOptions();
         } else {
             $statusOptions['multiOptions'] = [OpenSKOS_Concept_Status::APPROVED];
             $statusOptions['disabled'] = true;
         }
         $form->addElement('select', 'status', $statusOptions);
         $form->addElement('checkbox', 'ignoreIncomingStatus', array('label' => 'Ignore incoming status'));
         $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor');
         $form->addElement('select', 'lang', array('label' => 'The default language to use if no "xml:lang" attribute is found', 'multiOptions' => $editorOptions['languages']));
         $form->addElement('checkbox', 'toBeChecked', array('label' => 'Sets the toBeCheked status of imported concepts'));
         $form->addElement('checkbox', 'purge', array('label' => 'Purge. Delete all concept schemes found in the file. (will also delete concepts inside them)'));
         $form->addElement('checkbox', 'delete-before-import', array('label' => _('Delete concepts in this collection before import')));
         $form->addElement('checkbox', 'onlyNewConcepts', array('label' => _('Import contains only new concepts. Do not update any concepts if they match by notation (or uri if useUriAsIdentifier is used).')));
         $form->addElement('checkbox', 'useUriAsIdentifier', array('label' => _('Use uri as identifier if concept notation does not exist in the importing concept.')));
         $form->addElement('submit', 'submit', array('label' => 'Submit'));
     }
     return $form;
 }
开发者ID:olhsha,项目名称:OpenSKOS2tempMeertens,代码行数:29,代码来源:Collection.php

示例8: form

 /**
  * Gets the form for adding and editing a document
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     $config = Zend_Registry::get('config');
     $form = new Zend_Form();
     $form->setAttrib('id', 'documentForm')->setAttrib('enctype', 'multipart/form-data')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $file = $form->createElement('file', 'document', array('label' => 'Upload File:'));
     $file->setRequired(true)->addValidator('Count', false, 1)->addValidator('Size', false, 10240000)->addValidator('Extension', false, $config->user->fileUploadAllowableExtensions->val ? $config->user->fileUploadAllowableExtensions->val : "");
     if (!isset($values['workshopDocumentId'])) {
         $form->addElement($file);
     }
     $title = $form->createElement('text', 'description', array('label' => 'File Description:'));
     $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['description']) ? $values['description'] : '');
     $form->addElement($title);
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     $file->setDecorators(array('File', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))));
     if (isset($values['workshopDocumentId'])) {
         $workshopDocumentId = $form->createElement('hidden', 'workshopDocumentId');
         $workshopDocumentId->setValue($values['workshopDocumentId']);
         $workshopDocumentId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($workshopDocumentId);
     }
     return $form;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:34,代码来源:WorkshopDocument.php

示例9: createAssetstoreForm

 /** Create assetstore form */
 public function createAssetstoreForm()
 {
     $form = new Zend_Form();
     $action = $this->webroot . '/assetstore/add';
     $form->setAction($action);
     $form->setName('assetstoreForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'assetstoreForm');
     // Name of the assetstore
     $inputDirectory = new Zend_Form_Element_Text('name', array('label' => $this->t('Give a name'), 'id' => 'assetstorename'));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Input directory
     $basedirectory = new Zend_Form_Element_Text('basedirectory', array('label' => $this->t('Pick a base directory'), 'id' => 'assetstoreinputdirectory'));
     $basedirectory->setRequired(true);
     $form->addElement($basedirectory);
     // Assetstore type
     $assetstoretypes = array('0' => $this->t('Managed by MIDAS'), '1' => $this->t('Remotely linked'));
     // Amazon support is not yet implemented, don't present it as an option
     //                          '2' => $this->t('Amazon S3'));
     $assetstoretype = new Zend_Form_Element_Select('assetstoretype', array('id' => 'assetstoretype'));
     $assetstoretype->setLabel('Select a type')->setMultiOptions($assetstoretypes);
     // Add a loading image
     $assetstoretype->setDescription('<div class="assetstoreLoading" style="display:none"><img src="' . $this->webroot . '/core/public/images/icons/loading.gif"/></div>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $form->addElement($assetstoretype);
     // Submit
     $addassetstore = new Zend_Form_Element_Submit('addassetstore', $this->t('Add this assetstore'));
     $form->addElement($addassetstore);
     return $form;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:31,代码来源:AssetstoreForm.php

示例10: testPluginDoesNotModifyAutocompleteAttributeIfItIsAlreadyDefinedInTheForm

 /**
  * Ensures that the plugin does not modify the autocomplete attribute if it
  * is already defined in the form.
  */
 public function testPluginDoesNotModifyAutocompleteAttributeIfItIsAlreadyDefinedInTheForm()
 {
     $form = new Zend_Form();
     $form->setAttrib('autocomplete', 'any-value');
     $this->plugin->enhance($form);
     $this->assertEquals('any-value', $form->getAttrib('autocomplete'));
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:11,代码来源:AutoCompleteOffTest.php

示例11: getAddContentForm

 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;
 }
开发者ID:seant23,项目名称:red,代码行数:29,代码来源:ContentController.php

示例12: testCanAddAndRetrieveMultipleAttribs

 public function testCanAddAndRetrieveMultipleAttribs()
 {
     $this->form->setAttrib('foo', 'bar');
     $this->assertEquals('bar', $this->form->getAttrib('foo'));
     $this->form->addAttribs(array('bar' => 'baz', 'baz' => 'bat', 'bat' => 'foo'));
     $test = $this->form->getAttribs();
     $attribs = array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat', 'bat' => 'foo');
     $this->assertSame($attribs, $test);
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:9,代码来源:FormTest.php

示例13: enhance

 /**
  * Sets the autocomplete attribute of given form to "off".
  *
  * The plugin will not modify the form if it already has
  * an autocomplete attribute.
  *
  * @param Zend_Form $form
  */
 public function enhance(Zend_Form $form)
 {
     if ($form->getAttrib('autocomplete') !== null) {
         // Autocomplete attribute is already set for
         // this form instance.
         return;
     }
     $form->setAttrib('autocomplete', 'off');
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:17,代码来源:AutoCompleteOff.php

示例14: formAction

 public function formAction()
 {
     $form = new Zend_Form();
     $form->setAction('/resource/process')->setMethod('post');
     $form->setAttrib('id', 'login');
     $form->addElement('text', 'username');
     echo $form;
     exit;
 }
开发者ID:laiello,项目名称:xinhuxi,代码行数:9,代码来源:IndexController.php

示例15: indexAction

 function indexAction()
 {
     $this->setupCache('default');
     $this->level = 500;
     $this->requirePriviledges();
     $this->toTpl('theInclude', 'profile');
     $data = $this->_request->getParams();
     $this->toTpl('module_title', $this->t('Profile of') . " " . $data['profile']);
     //check if the user is trying to view his profile
     $edit = false;
     if ($data['profile'] == 'me' || !$data['profile'] || $data['profile'] == 'index') {
         $profile = $_SESSION['user']['username'];
         $edit = true;
     } else {
         $profile = $data['profile'];
         $edit = false;
     }
     //try to get the user...
     $user = $this->getUserByName($profile);
     //now we need to get the data for this user
     $user['data'] = $this->getUserData($user['id']);
     //now if the user is viewing his profile, we need to create a nice form in order for him to edit the data
     if ($edit) {
         //get the fields
         $fields = $this->getUserProfileFields();
         $form = new Zend_Form();
         $form->setView($this->tpl);
         $form->setAttrib('class', 'form');
         $form->removeDecorator('dl');
         $form->setAction($this->config->host->folder . '/profiles/update')->setMethod('post');
         foreach ($fields as $k => $v) {
             switch ($v['field_type']) {
                 case "selectbox":
                     $values = explode(",", $v['default_value']);
                     break;
                 default:
                     $values = $v['default_value'];
                     break;
             }
             $form->addElement($this->getFormElement(array('name' => $v['name'], 'value' => $v['field_type'], 'title' => $this->t(ucfirst($v['name'])), 'use_pool' => 'valuesAsKeys', 'pool_type' => $values, 'novalue' => true), $user['data'][$v['name']]));
         }
         $form->addElement($this->getFormElement(array('name' => 'uid', 'value' => 'hidden'), $user['id']));
         $submit = new Zend_Form_Element_Submit('save');
         $submit->setLabel($this->t("Update"));
         $submit->setAttrib('class', "btn btn-primary");
         $form->addElement($submit);
         $form = $this->doQoolHook('pre_assign_user_profile_form', $form);
         $this->toTpl('formTitle', $this->t("Update your profile"));
         $this->toTpl('theForm', $form);
         $user = $this->doQoolHook('pre_assign_profiles_own_user_data', $user);
     } else {
         $user = $this->doQoolHook('pre_assign_profiles_user_data', $user);
     }
     $this->doQoolHook('pre_load_profiles_tpl');
     $this->toTpl('user', $user);
 }
开发者ID:basdog22,项目名称:Qool,代码行数:56,代码来源:ProfilesController.php


注:本文中的Zend_Form::setAttrib方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。