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


PHP JForm::getField方法代码示例

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


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

示例1: getFormField

 /**
  * 
  * get some form field by looking it in all fieldsets
  */
 private static function getFormField(JForm $form, $fieldName)
 {
     $field = $form->getField($fieldName);
     if (!empty($field)) {
         return $field;
     }
     foreach (self::$arrGroupsAssoc as $group => $nothing) {
         $field = $form->getField($fieldName, $group);
         if (!empty($field)) {
             return $field;
         }
     }
     UniteFunctionsRev::throwError("Field not found: {$fieldName}");
 }
开发者ID:DanyCan,项目名称:wisten.github.io,代码行数:18,代码来源:controls.class.php

示例2: displayTask

 /**
  * Default view function
  *
  * @return void
  */
 public function displayTask()
 {
     // Get scope
     $this->view->scope = Request::getWord('scope', 'Hub');
     $this->view->scope_id = Request::getInt('scope_id', 0);
     // Get permissions
     $access = new \JForm('permissions');
     $access->loadFile(dirname(dirname(__DIR__)) . DS . 'models' . DS . 'forms' . DS . 'permissions.xml');
     // Bind existing rules if applicable
     $asset = new \JTableAsset($this->database);
     $name = 'com_time.' . strtolower($this->view->scope) . '.' . $this->view->scope_id;
     $asset->loadByName($name);
     if ($asset->get('id')) {
         $access->setValue('asset_id', null, $asset->get('id'));
     }
     $this->view->permissions = $access->getField(strtolower($this->view->scope));
     // Display
     $this->view->display();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:24,代码来源:permissions.php

示例3: onContentPrepareForm

    /**
     * Prepare form.
     *
     * @param   JForm  $form  The form to be altered.
     * @param   mixed  $data  The associated data for the form.
     *
     * @return  boolean
     *
     * @since	2.5
     */
    public function onContentPrepareForm($form, $data)
    {
        // Check we have a form.
        if (!$form instanceof JForm) {
            $this->_subject->setError('JERROR_NOT_A_FORM');
            return false;
        }
        // Check we are manipulating the languagecode plugin.
        if ($form->getName() != 'com_plugins.plugin' || !$form->getField('languagecodeplugin', 'params')) {
            return true;
        }
        // Get site languages.
        if ($languages = JLanguage::getKnownLanguages(JPATH_SITE)) {
            // Inject fields into the form.
            foreach ($languages as $tag => $language) {
                $form->load('
					<form>
						<fields name="params">
							<fieldset
								name="languagecode"
								label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL"
								description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC"
							>
								<field
									name="' . strtolower($tag) . '"
									type="text"
									description="' . htmlspecialchars(JText::sprintf('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '"
									translate_description="false"
									label="' . $tag . '"
									translate_label="false"
									size="7"
									filter="cmd"
								/>
							</fieldset>
						</fields>
					</form>
				');
            }
        }
        return true;
    }
开发者ID:deenison,项目名称:joomla-cms,代码行数:51,代码来源:languagecode.php

示例4: onContentPrepareForm

 public function onContentPrepareForm(JForm $form, $data)
 {
     $context = $form->getName();
     // Transform categories form name to a valid context
     if (strpos($context, 'com_categories.category') !== false) {
         $context = str_replace('com_categories.category', '', $context) . '.category';
     }
     // Extracting the component and section
     $parts = $this->getParts($context);
     if (!$parts) {
         return true;
     }
     // If we are on the save command we need the actual data
     $jformData = JFactory::getApplication()->input->get('jform', array(), 'array');
     if ($jformData && !$data) {
         $data = $jformData;
     }
     if (is_array($data)) {
         $data = (object) $data;
     }
     $component = $parts[0];
     $section = $parts[1];
     $catid = isset($data->catid) ? $data->catid : (isset($data->dpfieldscatid) ? $data->dpfieldscatid : null);
     if (!$catid && $form->getField('catid')) {
         // Choose the first category available
         $xml = new DOMDocument();
         $xml->loadHTML($form->getField('catid')->__get('input'));
         $options = $xml->getElementsByTagName('option');
         if ($firstChoice = $options->item(0)) {
             $catid = $firstChoice->getAttribute('value');
             $data->dpfieldscatid = $catid;
         }
     }
     // Getting the fields
     $fields = DPFieldsHelper::getFields($parts[0] . '.' . $parts[1], $data);
     // If there is a catid field we need to reload the page when the catid
     // is changed
     if ($form->getField('catid') && $parts[0] != 'com_dpfields') {
         // The uri to submit to
         $uri = clone JUri::getInstance('index.php');
         // Removing the catid parameter from the actual url and set it as
         // return
         $returnUri = clone JUri::getInstance();
         $returnUri->setVar('catid', null);
         $uri->setVar('return', base64_encode($returnUri->toString()));
         // Setting the options
         $uri->setVar('option', 'com_dpfields');
         $uri->setVar('task', 'field.catchange');
         $uri->setVar('context', $parts[0] . '.' . $parts[1]);
         $uri->setVar('formcontrol', $form->getFormControl());
         $uri->setVar('view', null);
         $uri->setVar('layout', null);
         // Setting the onchange event to reload the page when the category
         // has changed
         $form->setFieldAttribute('catid', 'onchange', "categoryHasChanged(this);");
         JFactory::getDocument()->addScriptDeclaration("function categoryHasChanged(element){\n\t\t\t\tvar cat = jQuery(element);\n\t\t\t\tif (cat.val() == '" . $catid . "')return;\n\t\t\t\tjQuery('input[name=task]').val('field.catchange');\n\t\t\t\telement.form.action='" . $uri . "';\n\t\t\t\telement.form.submit();\n\t\t\t}\n\t\t\tjQuery( document ).ready(function() {\n\t\t\t\tvar formControl = '#" . $form->getFormControl() . "_catid';\n\t\t\t\tif (!jQuery(formControl).val() != '" . $catid . "'){jQuery(formControl).val('" . $catid . "');}\n\t\t\t});");
     }
     if (!$fields) {
         return true;
     }
     // Creating the dom
     $xml = new DOMDocument('1.0', 'UTF-8');
     $fieldsNode = $xml->appendChild(new DOMElement('form'))->appendChild(new DOMElement('fields'));
     $fieldsNode->setAttribute('name', 'params');
     $fieldsNode->setAttribute('addfieldpath', '/administrator/components/com_dpfields/models/fields');
     $fieldsNode->setAttribute('addrulepath', '/administrator/components/com_dpfields/models/rules');
     // Defining the field set
     $fieldset = $fieldsNode->appendChild(new DOMElement('fieldset'));
     $fieldset->setAttribute('name', 'params');
     $fieldset->setAttribute('name', 'dpfields');
     $fieldset->setAttribute('addfieldpath', '/administrator/components/' . $component . '/models/fields');
     $fieldset->setAttribute('addrulepath', '/administrator/components/' . $component . '/models/rules');
     $lang = JFactory::getLanguage();
     $key = strtoupper($component . '_FIELDS_' . $section . '_LABEL');
     if (!$lang->hasKey($key)) {
         $key = 'PLG_SYSTEM_DPFIELDS_FIELDS';
     }
     $fieldset->setAttribute('label', JText::_($key));
     $key = strtoupper($component . '_FIELDS_' . $section . '_DESC');
     if ($lang->hasKey($key)) {
         $fieldset->setAttribute('description', JText::_($key));
     }
     // Looping trough the fields for that context
     foreach ($fields as $field) {
         // Creating the XML form data
         $type = DPFieldsHelper::loadTypeObject($field->type, $field->context);
         if ($type === false) {
             continue;
         }
         try {
             // Rendering the type
             $node = $type->appendXMLFieldTag($field, $fieldset, $form);
             // If the field belongs to a catid but the catid in the data is
             // not known, set the required flag to false on any circumstance
             if (!$catid && $field->catid) {
                 $node->setAttribute('required', 'false');
             }
         } catch (Exception $e) {
             JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
         }
//.........这里部分代码省略.........
开发者ID:brianteeman,项目名称:DPFields,代码行数:101,代码来源:dpfields.php


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