setName('form_config_general'); $this->setSubmitLabel(t('Save Changes')); } /** * @see Form::createElements() */ public function createElements(array $formData) { $appConfigForm = new ApplicationConfigForm(); $loggingConfigForm = new LoggingConfigForm(); $this->addElements($appConfigForm->createElements($formData)->getElements()); $this->addElements($loggingConfigForm->createElements($formData)->getElements()); } /** * @see Form::onSuccess() */ public function onSuccess(Request $request) { foreach ($this->getValues() as $sectionAndPropertyName => $value) { list($section, $property) = explode('_', $sectionAndPropertyName); if (isset($this->config->{$section})) { $this->config->{$section}->{$property} = $value; } else { $this->config->{$section} = array($property => $value); } } if ($this->save()) { Notification::success(t('New configuration has successfully been stored')); } else { return false; } } /** * @see Form::onRequest() */ public function onRequest(Request $request) { $values = array(); foreach ($this->config as $section => $properties) { foreach ($properties as $name => $value) { $values[$section . '_' . $name] = $value; } } $this->populate($values); } }