/** * Gets field list from $model basing on its Form annotation. * * @param object $model * @param string $form view * @return array list of fields (or empty for all fields) */ private function getFields($model, $form) { $ro = new \ReflectionObject($model); $formAnnotation = $this->annotationReader->getClassAnnotation($ro, 'Codete\\FormGeneratorBundle\\Annotations\\Form'); if (($formAnnotation === null || !$formAnnotation->hasForm($form)) && $ro->getParentClass()) { while ($ro = $ro->getParentClass()) { $formAnnotation = $this->annotationReader->getClassAnnotation($ro, 'Codete\\FormGeneratorBundle\\Annotations\\Form'); if ($formAnnotation !== null && $formAnnotation->hasForm($form)) { break; } } } if ($formAnnotation === null) { $formAnnotation = new Annotations\Form(array()); } return $formAnnotation->getForm($form); }
public function testNonDefaultForm() { $foo = array('foo' => 'bar', 'baz'); $f = new Form(array('foo' => $foo)); $this->assertSame($foo, $f->getForm('foo')); }