PMA\libraries\config\FormDisplay::registerForm PHP Method

registerForm() public method

Registers form in form manager
public registerForm ( string $form_name, array $form, integer $server_id = null ) : void
$form_name string Form name
$form array Form data
$server_id integer 0 if new server, validation; >= 1 if editing a server
return void
    public function registerForm($form_name, array $form, $server_id = null)
    {
        $this->_forms[$form_name] = new Form($form_name, $form, $this->_configFile, $server_id);
        $this->_isValidated = false;
        foreach ($this->_forms[$form_name]->fields as $path) {
            $work_path = $server_id === null ? $path : str_replace('Servers/1/', "Servers/{$server_id}/", $path);
            $this->_systemPaths[$work_path] = $path;
            $this->_translatedPaths[$work_path] = str_replace('/', '-', $work_path);
        }
    }

Usage Example

 /**
  * Test for FormDisplay::registerForm
  *
  * @return void
  * @group medium
  */
 public function testRegisterForm()
 {
     $reflection = new \ReflectionClass('PMA\\libraries\\config\\FormDisplay');
     $attrForms = $reflection->getProperty('_forms');
     $attrForms->setAccessible(true);
     $array = array("Servers" => array("1" => array('test' => 1, 1 => ':group:end')));
     $this->object->registerForm('pma_testform', $array, 2);
     $_forms = $attrForms->getValue($this->object);
     $this->assertInstanceOf('PMA\\libraries\\config\\Form', $_forms['pma_testform']);
     $this->assertEquals(array("Servers/2/test" => "Servers/1/test", "Servers/2/:group:end:0" => "Servers/1/:group:end:0"), $this->readAttribute($this->object, '_systemPaths'));
     $this->assertEquals(array("Servers/2/test" => "Servers-2-test", "Servers/2/:group:end:0" => "Servers-2-:group:end:0"), $this->readAttribute($this->object, '_translatedPaths'));
 }
All Usage Examples Of PMA\libraries\config\FormDisplay::registerForm