/** * {@inheritdoc} */ protected function addField($fieldPath, $id, $parentId = null) { $groupName = $this->findGroupName($fieldPath); if ($groupName) { $this->groups[$groupName]['hasFields'] = true; $parentId = $this->groups[$groupName]['id']; } parent::addField($fieldPath, $id, $parentId); }
public function testPreferredCompoundFields() { $options = $this->getOptions(); $options['preferred_fields'] = ['field2.field21']; $form = $this->getForm(); $formAccessor = new FormAccessor($form); $form->add($this->getForm(false, 'type1', 'field1')); $childForm = $this->getForm(true, 'type2', 'field2'); $childForm->add($this->getForm(false, 'type21', 'field21')); $form->add($childForm); $this->layoutManipulator->expects($this->at(0))->method('add')->with(self::FIELD_PREFIX . 'field2:field21', self::ROOT_ID, FormFieldType::NAME, ['form' => null, 'form_name' => self::FORM_NAME, 'field_path' => 'field2.field21'])->will($this->returnSelf()); $this->layoutManipulator->expects($this->at(1))->method('add')->with(self::FIELD_PREFIX . 'field1', self::ROOT_ID, FormFieldType::NAME, ['form' => null, 'form_name' => self::FORM_NAME, 'field_path' => 'field1'])->will($this->returnSelf()); $this->layoutManipulator->expects($this->exactly(2))->method('add'); $this->builder->build($formAccessor, $this->blockBuilder, $options); $this->assertSame(['field2.field21' => self::FIELD_PREFIX . 'field2:field21', 'field1' => self::FIELD_PREFIX . 'field1'], $formAccessor->getProcessedFields()); }