Clone this wiki locally
The idea behind FORM is to automatically generate forms and validators for models by using docblock annotations. Doctrine’s common library will be used for parsing the annotations, but Doctrine’s ORM and DBAL will not be required (although existing docblocks for Doctrine will be used for defaults when available). Zend_Form will be the default standard form implementation, although the idea is to extend this to other libraries as well.
Tentative example usage:
// Set up config $config = new \FORM\Configuration(); // Use Doctrine's annotations to populate basic metadata $metadataDriver = new \FORM\Mapping\Driver\DoctrineDriver($em); $config->setMetadataDriverImpl($metadataDriver); $fm = new \FORM\FormManager($config);
// Grab the object’s full form
$form = $fm→getRepository(‘Doctrine\Model’)→getForm();
// Grab a form element for the given model’s property
$element = $fm→getRepository(‘Doctrine\Model’)→getElement(‘id’);
These methods will return a proxy form (or a mediator), that has rules set up for transferring data between the underlying form and the object. This will contain methods like isValid and populate similarly to the form implementation, but will also have transferToObject and createObject functions. The transferToObject will rely on the user supplying an existing object of the correct type.