/** * @param array $conf an assoc array of parameters. these are: * - string name => $name of the propel object class * - string filename => $filename of the form definition xml file */ public static function create($conf) { extract($conf); $autoValidate = isset($autoValidate) ? $autoValidate : 'save'; $definition = new patForms_Definition_Propel($name, $autoValidate); if (0 and file_exists($filename)) { // load definition from xml file $definition->load($filename); } else { // populate definition from table map and save it to xml file $definition = self::populateFromTableMap($definition, $conf); $definition->save($filename); } return $definition; }
$path = PATH_SEPARATOR . $pathToBookstore . PATH_SEPARATOR . $pathToPat; set_include_path(get_include_path() . $path); // change these according to your propel settings $classname = 'book'; $path = './patForms/res'; $propelConfFilename = 'conf/bookstore-conf.php'; // uncomment this to edit an existing record $pk = array('Id' => 2); /** * the rest should work out of the box if you don't have any unusal * types in your database schema.xml (strings, int etc. should work) */ require_once 'bookstore/' . $classname . '.php'; Propel::init($propelConfFilename); // create a form definition $definition = patForms_Definition_Propel::create(array('name' => $classname, 'filename' => $path . '/form.' . $classname . '.xml')); // create a storage $storage = patForms::createStorage('Propel'); $storage->setStorageLocation($classname . 'peer'); // create a form $form =& patForms::createCreator('Definition')->create($definition); $form->setRenderer(patForms::createRenderer('Array')); $form->setStorage($storage); if (isset($pk)) { $form->setValues($pk); } // render it to a patTemplate (could be done by other template engines) $tpl = new patTemplate(); $tpl->setRoot($path); $tpl->readTemplatesFromInput('form.dynamic.tpl'); $tpl->addVar('page', 'title', 'Bookstore party');