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


PHP Form::create方法代码示例

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


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

示例1: testWhetherItIsPossibleToRecreateAForm

 /**
  * @depends testWhetherAUniqueFormIdIsBeingAdded
  * @depends testWhetherASubmitButtonIsAddedWithASubmitLabelBeingSet
  */
 public function testWhetherItIsPossibleToRecreateAForm()
 {
     $form = new Form();
     $form->setTokenDisabled();
     $form->setSubmitLabel('test');
     $form->create();
     // sets the flag $this->created to true
     $form->clearElements();
     // should reset the flag..
     $form->create();
     // ..so that we can recreate the form
     $this->assertCount(2, $form->getElements(), 'Form::clearElements() does not fully reset the form');
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:17,代码来源:FormTest.php

示例2: setupPage

 /**
  * Setup the given page that is either going to be displayed or validated
  *
  * @param   Form        $page       The page to setup
  * @param   Request     $request    The current request
  */
 public function setupPage(Form $page, Request $request)
 {
     if ($page->getName() === 'setup_requirements') {
         $page->setWizard($this);
     } elseif ($page->getName() === 'setup_authentication_backend') {
         $authData = $this->getPageData('setup_authentication_type');
         if ($authData['type'] === 'db') {
             $page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
         } elseif ($authData['type'] === 'ldap') {
             $page->setResourceConfig($this->getPageData('setup_ldap_resource'));
             $suggestions = $this->getPageData('setup_ldap_discovery');
             if (isset($suggestions['backend'])) {
                 $page->populate($suggestions['backend']);
             }
         }
         /*} elseif ($page->getName() === 'setup_ldap_discovery_confirm') {
           $page->setResourceConfig($this->getPageData('setup_ldap_discovery'));*/
     } elseif ($page->getName() === 'setup_admin_account') {
         $page->setBackendConfig($this->getPageData('setup_authentication_backend'));
         $authData = $this->getPageData('setup_authentication_type');
         if ($authData['type'] === 'db') {
             $page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
         } elseif ($authData['type'] === 'ldap') {
             $page->setResourceConfig($this->getPageData('setup_ldap_resource'));
         }
     } elseif ($page->getName() === 'setup_auth_db_creation' || $page->getName() === 'setup_config_db_creation') {
         $page->setDatabaseSetupPrivileges(array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges)));
         $page->setDatabaseUsagePrivileges($this->databaseUsagePrivileges);
         $page->setResourceConfig($this->getPageData('setup_auth_db_resource') ?: $this->getPageData('setup_config_db_resource'));
     } elseif ($page->getName() === 'setup_summary') {
         $page->setSubjectTitle('Icinga Web 2');
         $page->setSummary($this->getSetup()->getSummary());
     } elseif ($page->getName() === 'setup_config_db_resource') {
         $ldapData = $this->getPageData('setup_ldap_resource');
         if ($ldapData !== null && $request->getPost('name') === $ldapData['name']) {
             $page->error(mt('setup', 'The given resource name must be unique and is already in use by the LDAP resource'));
         }
     } elseif ($page->getName() === 'setup_ldap_resource') {
         $suggestion = $this->getPageData('setup_ldap_discovery');
         if (isset($suggestion['resource'])) {
             $page->populate($suggestion['resource']);
         }
     } elseif ($page->getName() === 'setup_general_config') {
         $authData = $this->getPageData('setup_authentication_type');
         if ($authData['type'] === 'db') {
             $page->create()->getElement('global_config_backend')->setValue('db');
             $page->info(mt('setup', 'Note that choosing "Database" as preference storage causes' . ' Icinga Web 2 to use the same database as for authentication.'), false);
         }
     } elseif ($page->getName() === 'setup_authentication_type' && $this->getDirection() === static::FORWARD) {
         $authData = $this->getPageData($page->getName());
         if ($authData !== null && $request->getPost('type') !== $authData['type']) {
             // Drop any existing page data in case the authentication type has changed,
             // otherwise it will conflict with other forms that depend on this one
             $pageData =& $this->getPageData();
             unset($pageData['setup_admin_account']);
             unset($pageData['setup_authentication_backend']);
             if ($authData['type'] === 'db') {
                 unset($pageData['setup_auth_db_resource']);
                 unset($pageData['setup_auth_db_creation']);
             } elseif ($request->getPost('type') === 'db') {
                 unset($pageData['setup_config_db_resource']);
                 unset($pageData['setup_config_db_creation']);
             }
         }
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:72,代码来源:WebWizard.php


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