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


PHP Zend_Form::setName方法代码示例

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


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

示例1: 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

示例2: createMigrateForm

 /** Main form */
 public function createMigrateForm($assetstores)
 {
     // Setup the form
     $form = new Zend_Form();
     $form->setAction('migratemidas2');
     $form->setName('migrateForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'migrateForm');
     // Input directory
     $midas2_hostname = new Zend_Form_Element_Text('midas2_hostname', array('label' => $this->t('MIDAS2 Hostname'), 'size' => 60, 'value' => 'localhost'));
     $midas2_hostname->setRequired(true);
     $form->addElement($midas2_hostname);
     $midas2_port = new Zend_Form_Element_Text('midas2_port', array('label' => $this->t('MIDAS2 Port'), 'size' => 4, 'value' => '5432'));
     $midas2_port->setRequired(true);
     $midas2_port->setValidators(array(new Zend_Validate_Digits()));
     $form->addElement($midas2_port);
     $midas2_user = new Zend_Form_Element_Text('midas2_user', array('label' => $this->t('MIDAS2 User'), 'size' => 60, 'value' => 'midas'));
     $midas2_user->setRequired(true);
     $form->addElement($midas2_user);
     $midas2_password = new Zend_Form_Element_Password('midas2_password', array('label' => $this->t('MIDAS2 Password'), 'size' => 60, 'value' => 'midas'));
     $midas2_password->setRequired(true);
     $form->addElement($midas2_password);
     $midas2_database = new Zend_Form_Element_Text('midas2_database', array('label' => $this->t('MIDAS2 Database'), ' size' => 60, 'value' => 'midas'));
     $midas2_database->setRequired(true);
     $form->addElement($midas2_database);
     $midas2_assetstore = new Zend_Form_Element_Text('midas2_assetstore', array('label' => $this->t('MIDAS2 Assetstore Path'), 'size' => 60, 'value' => 'C:/xampp/midas/assetstore'));
     $midas2_assetstore->setRequired(true);
     $form->addElement($midas2_assetstore);
     // Button to select the directory on the server
     $midas2_assetstore_button = new Zend_Form_Element_Button('midas2_assetstore_button', $this->t('Choose'));
     $midas2_assetstore_button->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
     $form->addElement($midas2_assetstore_button);
     // Assetstore
     $assetstoredisplay = array();
     $assetstoredisplay[0] = $this->t('Choose one...');
     // Initialize with the first type (MIDAS)
     foreach ($assetstores as $assetstore) {
         if ($assetstore->getType() == 0) {
             $assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
         }
     }
     $assetstore = new Zend_Form_Element_Select('assetstore');
     $assetstore->setLabel($this->t('MIDAS3 Assetstore'));
     $assetstore->setMultiOptions($assetstoredisplay);
     $assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $assetstore->setRequired(true);
     $assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
     $assetstore->setRegisterInArrayValidator(false);
     // This array is dynamic so we disable the validator
     $form->addElement($assetstore);
     // Submit
     $submit = new Zend_Form_Element_Button('migratesubmit', $this->t('Migrate'));
     $form->addElement($submit);
     return $form;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:56,代码来源:MigrateForm.php

示例3: __construct

 /**
  * Construct the bridge while setting the model.
  *
  * Extra parameters can be added in subclasses, but the first parameter
  * must remain the model.
  *
  * @param \MUtil_Model_ModelAbstract $model
  * @param \Zend_Form $form Rquired
  */
 public function __construct(\MUtil_Model_ModelAbstract $model, \Zend_Form $form = null)
 {
     $this->model = $model;
     $this->form = $form;
     if (!$form instanceof \Zend_Form) {
         throw new \MUtil_Model_ModelException("No form specified while create a form bridge for model " . $model->getName());
     }
     if (!$form->getName()) {
         $form->setName($model->getName());
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:20,代码来源:FormBridge.php

示例4: testElementsRenderAsMembersOfSubFormsWithElementsBelongTo

 public function testElementsRenderAsMembersOfSubFormsWithElementsBelongTo()
 {
     $this->form->setName('data')->setIsArray(true);
     $subForm = new Zend_Form_SubForm();
     $subForm->setElementsBelongTo('billing[info]');
     $subForm->addElement('text', 'name');
     $subForm->addElement('text', 'number');
     $this->form->addSubForm($subForm, 'sub');
     $html = $this->form->render($this->getView());
     $this->assertContains('name="data[billing][info][name]', $html);
     $this->assertContains('name="data[billing][info][number]', $html);
     $this->assertContains('id="data-billing-info-name"', $html);
     $this->assertContains('id="data-billing-info-number"', $html);
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:14,代码来源:FormTest.php

示例5: testRenderWithHidden

 public function testRenderWithHidden()
 {
     $form = new Zend_Form();
     $form->setName('Test');
     $form->addElement('submit', 'Remove');
     $element = $form->createElement('hidden', 'Id');
     $element->setValue(10);
     $form->addElement($element);
     $decorator = new Application_Form_Decorator_RemoveButton();
     $decorator->setElement($form);
     $decorator->setSecondElement($element);
     $output = $decorator->render('content');
     // Output wird an content dran gehängt
     $this->assertEquals('content' . '<input type="hidden" name="Id" id="Id" value="10" />' . '<input type="submit" name="Remove" id="Remove" value="Remove" />', $output);
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:15,代码来源:RemoveButtonTest.php

示例6: _getLoginForm

 private function _getLoginForm()
 {
     $form = new Zend_Form();
     $form->setMethod('POST');
     $form->setName('userLoginForm');
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('User name')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Alnum')->addValidator('StringLength', false, array(3, 24));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password')->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(6));
     $realm = new Zend_Form_Element_Select('realm');
     $realm->setLabel('Role')->addMultiOptions(array('user' => 'User', 'admin' => 'Admin'))->setRequired(true)->setValue('user');
     $rememberMe = new Zend_Form_Element_Checkbox('rememberMe');
     $rememberMe->setLabel('Remember Me');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Login');
     $form->addElements(array($realm, $username, $password, $rememberMe, $submit));
     return $form;
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:18,代码来源:LoginController.php

示例7: getForm

 public function getForm()
 {
     $db = $this->db;
     $form = new Zend_Form();
     $form->setAction('/Account');
     $form->setMethod('get');
     $form->setName('search');
     $accountName = $form->createElement('text', 'name');
     $accountName->setLabel('Name');
     $city = $form->createElement('text', 'city');
     $city->setLabel('City');
     $state = $form->createElement('text', 'state');
     $state->setLabel('State');
     $country = $form->createElement('text', 'country');
     $country->setLabel('Country');
     $assignedTo = new Zend_Dojo_Form_Element_FilteringSelect('assignedTo');
     $assignedTo->setLabel('Accounts assigned to')->setAutoComplete(true)->setStoreId('accountStore')->setStoreType('dojo.data.ItemFileReadStore')->setStoreParams(array('url' => '/user/jsonstore'))->setAttrib("searchAttr", "email")->setRequired(false);
     $branchId = new Zend_Dojo_Form_Element_FilteringSelect('branchId');
     $branchId->setLabel('Accounts Of Branch')->setAutoComplete(true)->setStoreId('branchStore')->setStoreType('dojo.data.ItemFileReadStore')->setStoreParams(array('url' => '/jsonstore/branch'))->setAttrib("searchAttr", "branch_name")->setRequired(false);
     $submit = $form->createElement('submit', 'submit')->setLabel('Search')->setAttrib("class", "submit_button");
     $form->addElements(array($name, $city, $assignedTo, $branchId, $submit));
     return $form;
 }
开发者ID:BGCX262,项目名称:zurmo-b-2013-svn-to-git,代码行数:23,代码来源:Search.php

示例8: getForm

 /**
  * Returns a Form builds from widget's form definition or instanciated from given classname
  *
  * Form definition:
  *
  * A widget can define one or more Form in its xml description file. A Form can be used, either as main output of
  * the widget, or on the dashboard screen for setting purpose. When you pass a Form name as argument, this method
  * will try to retrieve the associated Form definition and build the Form from it.
  *
  * Form class:
  *
  * It's also possible to pass an associative array where the key is a Form classname and the value, the path where
  * to find the file that contains the class. It this case, An instance of the class will be created and returned.
  *
  * Common treatment:
  *
  * In all cases, if the Form's target is the dashboard screen, a specific hidden field is added to it. Also, if the
  * Form has not submit element, it's automatically generated and added to it.
  *
  * Alternative way:
  *
  * The alternative way is to override this method in subclass and build your Form into it directly. Note that the
  * {@link iPMS_Widget::getForm()} method is used both to retrieve Form for main output of the widget, and the
  * dashboard screen.
  *
  * @throws iPMS_Widgets_Exception if form definition was not found
  * @throws iPMS_Widgets_Exception if form class was not found
  * @param string|array $form Either a Form name to build from  a Form's definition, or an array where the key is the
  * Form classname and the value, the path where to find it
  * @return Zend_Form a Zend_Form object
  */
 public function getForm($form)
 {
     if (is_string($form)) {
         // Form generated from Form definition
         if (isset($this->_formInstances[$form])) {
             return $this->_formInstances[$form];
         }
         $formDef = $this->getFormDefinition($form);
         if (!array_key_exists('type', $formDef['element'])) {
             $formDef = $formDef['element'];
         }
         $elementStack = array();
         foreach ($formDef as $elementDef) {
             /**
              * @var $element Zend_Form_Element|Zend_Form_Element_Select
              */
             $className = 'Zend_Form_Element_' . ucfirst($elementDef['type']);
             $element = new $className($elementDef['name'], array('label' => isset($elementDef['label']) ? $elementDef['label'] : '', 'value' => isset($elementDef['val']) ? $elementDef['val'] : '', 'helper' => 'form' . ucfirst($elementDef['type']), 'required' => isset($elementDef['required']) ? (int) $elementDef['required'] : 0));
             if ($elementDef['type'] == 'select') {
                 if (isset($elementDef['option'])) {
                     foreach ($elementDef['option'] as $option) {
                         $element->addMultiOptions(array($option['val'] => $option['label']));
                         if (isset($option['selected'])) {
                             $element->setValue($option['val']);
                         }
                     }
                 } elseif (isset($elementDef['callback'])) {
                     if (isset($elementDef['callback']['function'])) {
                         $options = call_user_func_array($elementDef['callback']['function'], (array) isset($elementDef['callback']['argument']) ? $elementDef['callback']['argument'] : array());
                         if ($elementDef['callback']['function'] == 'range') {
                             $options = array_combine($options, $options);
                         }
                         $element->addMultiOptions($options);
                         if (isset($elementDef['callback']['selected'])) {
                             $element->setValue($elementDef['callback']['selected']);
                         }
                     } else {
                         require_once 'iPMS/Widgets/Exception.php';
                         throw new iPMS_Widgets_Exception('Unable to generate element options from callback: function name not found');
                     }
                 } else {
                     require_once 'iPMS/Widgets/Exception.php';
                     throw new iPMS_Widgets_Exception('All select elements must have options');
                 }
             }
             if (isset($elementDef['id'])) {
                 // Optional CSS id for element
                 $element->setAttrib('id', $elementDef['id']);
             }
             if (isset($elementDef['class'])) {
                 // Optional CSS class for element
                 $element->setAttrib('class', $elementDef['class']);
             }
             if (isset($elementDef['filter'])) {
                 // Optional filter(s) for element
                 $element->addFilters((array) $elementDef['filter']);
             }
             // Optional validator for element
             if (isset($elementDef['validator'])) {
                 // Optional validator for element
                 $element->addValidators((array) $elementDef['validator']);
             }
             $elementStack[] = $element;
         }
         // Creating new form instance
         $formInstance = new Zend_Form();
         $formInstance->setName($form)->setElementsBelongTo($form)->addElements($elementStack);
         // Optional description for the Form
         if (isset($formDef['description'])) {
//.........这里部分代码省略.........
开发者ID:nuxwin,项目名称:i-PMS,代码行数:101,代码来源:Widget.php

示例9: addSubForm

 /**
  * Add a form group/subform
  *
  * @param  Zend_Form $form
  * @param  string $name
  * @param  int $order
  * @return Zend_Form
  */
 public function addSubForm(Zend_Form $form, $name, $order = null)
 {
     $name = (string) $name;
     foreach ($this->_loaders as $type => $loader) {
         $loaderPaths = $loader->getPaths();
         foreach ($loaderPaths as $prefix => $paths) {
             foreach ($paths as $path) {
                 $form->addPrefixPath($prefix, $path, $type);
             }
         }
     }
     if (!empty($this->_elementPrefixPaths)) {
         foreach ($this->_elementPrefixPaths as $spec) {
             list($prefix, $path, $type) = array_values($spec);
             $form->addElementPrefixPath($prefix, $path, $type);
         }
     }
     if (!empty($this->_displayGroupPrefixPaths)) {
         foreach ($this->_displayGroupPrefixPaths as $spec) {
             list($prefix, $path) = array_values($spec);
             $form->addDisplayGroupPrefixPath($prefix, $path);
         }
     }
     if (null !== $order) {
         $form->setOrder($order);
     }
     $form->setName($name);
     $this->_subForms[$name] = $form;
     $this->_order[$name] = $order;
     $this->_orderUpdated = true;
     return $this;
 }
开发者ID:hansenmakangiras,项目名称:yiiframework-cms,代码行数:40,代码来源:Form.php

示例10: array

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
/**
 * @file form.php
 */
// Load Zend Framework
set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), __DIR__ . '/')));
// Create the auto loader so zend can load the rest automatically
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$form = new Zend_Form();
// Set form name, id, method and action
$form->setName('fileUpload')->setAttrib('id', 'fileUpload')->setMethod('post')->setAttrib('enctype', 'multipart/form-data')->setAction('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$file = new Zend_Form_Element_File('file');
$file->setLabel('File')->setRequired(true)->setValueDisabled(False)->addValidator('Extension', FALSE, 'jpg,jpeg')->addValidator('Size', false, array('min' => 20, 'max' => 20000000));
$file->getValidator('Extension')->setMessage('JPEGs only');
// Create text area for message
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message');
// Create a submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit')->setAttrib('id', 'submit');
// Set the ViewScript decorator for the form and tell it which
// template file to use
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php'))));
// Add the form elements AFTER the viewscript decorator has been set
$form->addElements(array($file, $message, $submit));
// Get rid of all element decorators except for ViewHelper to render
// the individual elements and Errors decorator to render the errors.
开发者ID:rmuktader,项目名称:zf-stand-alone-upload-form,代码行数:31,代码来源:form.php

示例11: createImportForm

 /** Main form */
 public function createImportForm($assetstores)
 {
     // Setup the form
     $form = new Zend_Form();
     $form->setAction('import/import');
     $form->setName('importForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'importForm');
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     // Hidden upload id
     $uploadId = new Zend_Form_Element_Hidden('uploadid', array('value' => $randomComponent->generateInt()));
     $uploadId->setDecorators(array('ViewHelper', array('HtmlTag', array('style' => 'display:none')), array('Label', array('style' => 'display:none'))));
     $form->addElement($uploadId);
     // Input directory
     $inputDirectory = new Zend_Form_Element_Text('inputdirectory', array('label' => $this->t('Directory on the server'), 'id' => 'inputdirectory', 'size' => 60));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Button to select the directory on the server
     $inputDirectoryButton = new Zend_Form_Element_Button('inputdirectorybutton', $this->t('Choose'));
     $inputDirectoryButton->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
     $form->addElement($inputDirectoryButton);
     // Select the assetstore type
     $assetstoretypes = array();
     $assetstoretypes[MIDAS_ASSETSTORE_LOCAL] = $this->t('Copy data on this server');
     // manage by MIDAS
     $assetstoretypes[MIDAS_ASSETSTORE_REMOTE] = $this->t('Link data from its current location');
     // link the data
     $assetstoretype = new Zend_Form_Element_Select('importassetstoretype');
     $assetstoretype->setLabel($this->t('Storage type'));
     $assetstoretype->setMultiOptions($assetstoretypes);
     $assetstoretype->setAttrib('onChange', 'assetstoretypeChanged()');
     $form->addElement($assetstoretype);
     // Assetstore
     $assetstoredisplay = array();
     $assetstoredisplay[0] = $this->t('Choose one...');
     // Initialize with the first type (MIDAS)
     foreach ($assetstores as $assetstore) {
         if ($assetstore->getType() == 0) {
             $assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
         }
     }
     $assetstore = new Zend_Form_Element_Select('assetstore');
     $assetstore->setLabel($this->t('Assetstore'));
     $assetstore->setMultiOptions($assetstoredisplay);
     $assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $assetstore->setRequired(true);
     $assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
     $assetstore->setRegisterInArrayValidator(false);
     // This array is dynamic so we disable the validator
     $form->addElement($assetstore);
     // Import empty directories
     $emptydirs = new Zend_Form_Element_Checkbox('importemptydirectories');
     $emptydirs->setLabel($this->t('Import empty directories'))->setChecked(true);
     $form->addElement($emptydirs);
     // Where to import the data
     $importFolder = new Zend_Form_Element_Text('importFolder', array('label' => $this->t('Folder Id'), 'id' => 'importFolder', 'size' => 3, 'value' => 1));
     $importFolder->setRequired(true);
     $form->addElement($importFolder);
     // Hidden filed to pass the translation of the stop import
     $stopimport = new Zend_Form_Element_Hidden('importstop', array('value' => $this->t('Stop import')));
     $stopimport->setDecorators(array('ViewHelper', array('HtmlTag', array()), array('Label', array()), 'Errors'));
     $form->addElement($stopimport);
     // Submit
     $submit = new Zend_Form_Element_Button('importsubmit', $this->t('Import data'));
     $form->addElement($submit);
     return $form;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:69,代码来源:ImportForm.php

示例12: array

<?php

/**
 * @file form.php
 */
// Load Zend Framework
set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), __DIR__ . '/')));
// Create the auto loader so zend can load the rest automatically
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$form = new Zend_Form();
// Set form name, id, method and action
$form->setName('contact')->setAttrib('id', 'form-contact')->setMethod('post')->setAction('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
// Create text box for name
$name = new Zend_Form_Element_Text('name');
$name->setRequired(TRUE)->setAttrib('id', 'fullname')->addErrorMessage('Please provide your name');
// Create text box for email
$email = new Zend_Form_Element_Text('email');
$email->setRequired(TRUE)->setAttrib('id', 'email')->addErrorMessage('Please provide a valid e-mail address');
// Create text area for message
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message');
// Create a submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Send Your Message!')->setAttrib('id', 'submit');
// Set the ViewScript decorator for the form and tell it which
// template file to use
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php'))));
// Add the form elements AFTER the viewscript decorator has been set
$form->addElements(array($name, $email, $message, $submit));
// Get rid of all element decorators except for ViewHelper to render
开发者ID:rmuktader,项目名称:zf-stand-alone-form,代码行数:31,代码来源:form.php

示例13: testFieldsetIdOverridesFormId

 /**
  * @group ZF-10679
  */
 public function testFieldsetIdOverridesFormId()
 {
     $form = new Zend_Form();
     $form->setName('bar')->setAttrib('id', 'form-id')->setView($this->getView());
     $html = $this->decorator->setElement($form)->setOption('id', 'fieldset-id')->render('content');
     $this->assertContains('<fieldset id="fieldset-id"', $html);
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:10,代码来源:FieldsetTest.php

示例14: setForm

		function setForm()
		{
			$form=new Zend_Form();
			$form->setMethod('post');
			$form->setName('insertForm');
			$form->setAction($this->view->baseUrl().'/admin/tintuc/insert');
			
			$form->addElement('text','news_title');
			$news_login=$form->getElement('news_title');
			$news_login->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống'));;
			$news_login->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$el=$form->createElement('textarea','news_avatar', array('style'=>'height:100px'));
			$el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Avatar không được để trống'));
			$el->setAttrib('id', 'news_avatar');
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($el);
			
			$el=$form->createElement('textarea','news_summary', array('style'=>'height:100px'));
			$el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mục tóm tắt không được để trống'));
			$el->setAttrib('id', 'news_summary');
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($el);
			
			$el=$form->createElement('textarea','news_content', array('style'=>'height:300px'));
			$el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Nội dung không được để trống'));;
			$el->setAttrib('id', 'news_content');
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($el);
			
			$form->addElement('text','news_author');
			$el=$form->getElement('news_author');
			$el->setValue($_SESSION['user']);
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$form->addElement('text','news_post_date');
			$el=$form->getElement('news_post_date');
			$el->setAttrib('class', 'datepicker');
			$el->setValue(date("Y-m-d",time()+7*3600));
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$form->addElement('text','news_modified_date');
			$el=$form->getElement('news_modified_date');
			$el->setAttrib('class', 'datepicker');
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			if ($_SESSION['role_id']==0) {
				$el=$form->createElement('select', 'news_status', array('multioptions'=>array('Chưa duyệt'=>'Chưa duyệt',
																						'Đã duyệt'=>'Đã duyệt',
																						'Riêng tư'=>'Riêng tư',
																						'Công khai'=>'Công khai')));
			} else if ($_SESSION['role_id']==1) {
				$el=$form->createElement('select', 'news_status', array('multioptions'=>array(	'Đã duyệt'=>'Đã duyệt',
																								'Riêng tư'=>'Riêng tư',
																								'Công khai'=>'Công khai')));
			} else {
				$el=$form->createElement('select', 'news_status', array('multioptions'=>array(	'Chưa duyệt'=>'Chưa duyệt',
																								'Đã duyệt'=>'Đã duyệt')));
			}
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($el);
			
			$is_hot= new Zend_Form_Element_Radio('is_hot');
			$is_hot->setRequired(true)
				->setLabel('Is hot?')
				->setMultiOptions(array(
                                                                      "0" => "Không",
                                                                      "1" => "Có"));
																	  
			$is_hot->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($is_hot);
			
			$listarray=array();
			if ($_SESSION['role_id']==0)
			{
				$listCategories=$this->mdanhmuc->getListCM();
				foreach ($listCategories as $category)
				{
					if ($this->mtintuc->countChildById($category['category_id'])==0)
						$listarray[$category['category_id']]=$category['category_name'];
				}
			}
			else 
			{
				$userID=$_SESSION['user_id'];
				$categoriesId=$this->mtintuc->getCategoryIDByUserId($userID);
				foreach ($categoriesId as $categoryId)
				{
					$category=$this->mtintuc->getCategoryById($categoryId);
					if ($this->mtintuc->countChildById($category['category_id'])==0)
						$listarray[$category['category_id']]=$category['category_name'];
				}
			}
			
			$el=$form->createElement("select","category_id",array(
                                                 "multioptions"=> $listarray));
			$el->removeDecorator('HtmlTag')->removeDecorator('Label');
			$form->addElement($el);
			
			return $form;
//.........这里部分代码省略.........
开发者ID:hungnv0789,项目名称:vhtm,代码行数:101,代码来源:TintucController.php

示例15: testNameAttributeOutputForXhtml

 public function testNameAttributeOutputForXhtml()
 {
     // Create form
     $form = new Zend_Form();
     $form->setName('foo');
     $form->setMethod(Zend_Form::METHOD_GET);
     $form->removeDecorator('HtmlTag');
     // Set doctype
     $this->getView()->getHelper('doctype')->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
     $expected = '<form id="foo" method="get" action="">' . PHP_EOL . '</form>';
     $this->assertSame($expected, $form->render($this->getView()));
 }
开发者ID:baofeng-beijing,项目名称:zf1.11.x,代码行数:12,代码来源:FormTest.php


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