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


PHP JForm::getFormControl方法代码示例

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


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

示例1: testGetFormControl

 /**
  * Test the JForm::getFormControl method.
  *
  * @return void
  */
 public function testGetFormControl()
 {
     $form = new JForm('form8ion');
     $this->assertThat($form->getFormControl(), $this->equalTo(''), 'Line:' . __LINE__ . ' A form control that has not been specified should return nothing.');
     $form = new JForm('form8ion', array('control' => 'jform'));
     $this->assertThat($form->getFormControl(), $this->equalTo('jform'), 'Line:' . __LINE__ . ' The form control should agree with the options passed in the constructor.');
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:12,代码来源:JFormTest.php

示例2: setForm

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   JForm  $form  The JForm object to attach to the form field.
  *
  * @return  JFormField  The form field object so that the method can be used in a chain.
  *
  * @since   11.1
  */
 public function setForm(JForm $form)
 {
     $this->form = $form;
     $this->formControl = $form->getFormControl();
     return $this;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:15,代码来源:field.php

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