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


PHP JForm::load方法代码示例

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


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

示例1: testGetInput

 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="mysqli" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "Mysqli" option.');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="non-existing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "None" option.');
     // TODO: Should check all the attributes have come in properly.
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:20,代码来源:JFormFieldDatabaseConnectionTest.php

示例2: testGetInput

 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     // Test a traditional hidden field type.
     $this->assertThat($form->load('<form><field name="hidden" type="hidden" label="foo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $this->assertEmpty($form->getLabel('hidden'), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.');
     // Test a field with attribute hidden = true.
     $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $this->assertEmpty($form->getLabel('hidden'), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.');
     // Test a field with attribute hidden = false.
     $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="false" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $matcher = array('id' => 'hidden-lbl', 'tag' => 'label', 'attributes' => array('for' => 'hidden', 'class' => ''), 'content' => 'regexp:/foo/');
     $this->assertTag($matcher, $form->getLabel('hidden'), 'Line:' . __LINE__ . ' The label of a non-hidden element should be some HTML.');
 }
开发者ID:akirsoft,项目名称:joomla-cms,代码行数:19,代码来源:JFormFieldHiddenTest.php

示例3: preprocessForm

 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since    3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'jevents')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_article');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
开发者ID:site4com,项目名称:prometheus,代码行数:41,代码来源:icalevent.php

示例4: testGetInput

 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     // Test a traditional hidden field type.
     $this->assertThat($form->load('<form><field name="hidden" type="hidden" label="foo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHidden($form);
     $this->assertThat($form->getLabel('hidden'), $this->equalTo(''), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.');
     // Test a field with attribute hidden = true.
     $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHidden($form);
     $this->assertThat($form->getLabel('hidden'), $this->equalTo(''), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.');
     // Test a field with attribute hidden = false.
     $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="false" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHidden($form);
     $this->assertThat($form->getLabel('hidden'), $this->equalTo('<label id="hidden-lbl" for="hidden" class="">foo</label>'), 'Line:' . __LINE__ . ' The label of a non-hidden element should be some HTML.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:21,代码来源:JFormFieldHiddenTest.php

示例5: render

 /**
  * Render HTML Markup for administrator UI
  *
  * @return  string
  */
 public function render()
 {
     $adminFormXml = $this->_generateFormXML();
     // Create form instance
     $this->adminForm = new JForm('template-setting');
     $this->adminForm->addFieldPath(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/form/fields');
     $this->adminForm->load($adminFormXml->asXML());
     $params = $this->helper->loadParams($this->data->params, $this->data->template);
     // Bind value of parameters to form
     foreach ($params as $key => $value) {
         $this->adminForm->setValue($key, 'jsn', $value);
     }
     // Get Joomla application object
     $app = JFactory::getApplication();
     // Store current compression parameters
     $app->setUserState('jsn.template.maxCompressionSize', $params['maxCompressionSize']);
     $app->setUserState('jsn.template.cacheDirectory', $params['cacheDirectory']);
     // Start rendering
     ob_start();
     include JSN_PATH_TPLFRAMEWORK_LIBRARIES . '/template/tmpl/default.php';
     $body = ob_get_clean();
     // Detect method to use for getting and setting response body
     if (version_compare(JVERSION, '3.2.0', 'ge')) {
         $get = array($app, 'getBody');
         $set = array($app, 'setBody');
     } else {
         $get = array('JResponse', 'getBody');
         $set = array('JResponse', 'setBody');
     }
     // Parse current response body
     list($head, $tmp) = preg_split('/<form[^>]+name="adminForm"[^>]*>/', call_user_func($get), 2);
     list($tmp, $foot) = explode('</form>', $tmp, 2);
     // Replace current response body
     call_user_func($set, $head . $body . $foot);
 }
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:40,代码来源:admin.php

示例6: testGetInput

 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="combo" type="combo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldCombo($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:12,代码来源:JFormFieldComboTest.php

示例7: testGetInput

 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="accesslevel" type="accesslevel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldAccessLevel($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:15,代码来源:JFormFieldAccessLevelTest.php

示例8: testGetInput

 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="color" type="color" disabled="true" onchange="window.reload()" class="inputbox" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldColor($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:15,代码来源:JFormFieldColorTest.php

示例9: testGetOptions

 /**
  * Test the getOptions method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetOptions()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="radio" type="radio"><option value="0">No</option><item value="1">Yes</item></field></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRadio($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->logicalNot($this->StringContains('Yes')), 'Line:' . __LINE__ . ' The field should not contain a Yes option.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:15,代码来源:JFormFieldRadioTest.php

示例10: testGetInput

 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="moduletag" type="moduletag" label="Module Tag" description="Module Tag listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldModuletag($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="nav">nav</option>', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with various opening tags, verify nav tag is in list.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:15,代码来源:JFormFieldModuletagTest.php

示例11: testGetInput

 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="helpsite" type="helpsite" label="Help Site" description="Help Site listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHelpsite($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="http://help.joomla.org/proxy/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with a link to the help site.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:15,代码来源:JFormFieldHelpsiteTest.php

示例12: testConstruct

 /**
  * Tests the JForm::__construct method
  */
 public function testConstruct()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     $this->assertThat($field instanceof JFormField, $this->isTrue(), 'Line:' . __LINE__ . ' The JFormField constuctor should return a JFormField object.');
     $this->assertThat($field->getForm(), $this->identicalTo($form), 'Line:' . __LINE__ . ' The internal form should be identical to the variable passed in the contructor.');
 }
开发者ID:nibra,项目名称:joomla-platform,代码行数:11,代码来源:JFormFieldTest.php

示例13: testGetInput

 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  * @todo    Should check all the attributes have come in properly.
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="componentlayout" type="componentlayout" extension="com_content" client_id="0" view="blog" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldComponentlayout($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:16,代码来源:JFormFieldComponentLayoutTest.php

示例14: testGetInput

 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="filelist" type="filelist" directory="modules/mod_finder/tmpl" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldFileList($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:16,代码来源:JFormFieldFileListTest.php

示例15: testGetInput

 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="rules" type="rules" section="component" component="com_content" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRules($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:14,代码来源:JFormFieldRulesTest.php


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