/** * @param FormBuilderInterface $form * @param FieldNodeDefinition $fieldDefinition */ protected function addFieldToForm(FormBuilderInterface $form, FieldNodeDefinition $fieldDefinition) { if ($fieldDefinition->getAclResource() && !$this->checkIsGranted($fieldDefinition->getAclResource())) { // field is not allowed to be shown, do nothing return; } $name = str_replace(ConfigManager::SECTION_MODEL_SEPARATOR, ConfigManager::SECTION_VIEW_SEPARATOR, $fieldDefinition->getName()); // take config field options form field definition $configFieldOptions = array_intersect_key($fieldDefinition->getOptions(), array_flip(['label', 'required', 'block', 'subblock', 'tooltip', 'resettable'])); // pass only options needed to "value" form type $configFieldOptions['target_field_type'] = $fieldDefinition->getType(); $configFieldOptions['target_field_options'] = array_diff_key($fieldDefinition->getOptions(), $configFieldOptions); $form->add($name, 'oro_config_form_field_type', $configFieldOptions); }
public function testGetOptions() { // options come from definition $node = new FieldNodeDefinition(self::TEST_NAME, $this->testDefinition); $this->assertEquals(self::TEST_ACL, $node->getAclResource()); // options come from setter $options = array('another_opt' => 'another_value'); $node = new FieldNodeDefinition(self::TEST_NAME, array()); $node->setOptions($options); $this->assertEquals($options, $node->getOptions()); // option override $node->replaceOption('another_opt', 'newValue'); $options = $node->getOptions(); $this->assertArrayHasKey('another_opt', $options); $this->assertEquals('newValue', $options['another_opt']); }
protected function addFieldToForm(FormBuilderInterface $form, FieldNodeDefinition $fieldDefinition) { if ($fieldDefinition->getAclResource() && !$this->checkIsGranted($fieldDefinition->getAclResource())) { // field is not allowed to be shown, do nothing return; } $name = str_replace(ConfigManager::SECTION_MODEL_SEPARATOR, ConfigManager::SECTION_VIEW_SEPARATOR, $fieldDefinition->getName()); $form->add($name, 'oro_config_form_field_type', $fieldDefinition->toFormFieldOptions()); }