*/
require_once 'patForms.php';
/**
 * patErrorManager class
 */
require_once 'patErrorManager.php';
// create the creator :)
$creator =& patForms::createCreator('Propel');
// create the form object from the given propel Object class instance
require_once 'model/general/UserProfile.php';
$userProfile = UserProfilePeer::retrieveByPK(1);
$form =& $creator->create($userProfile);
//$wikipage = WikipagePeer::retrieveByPK('wiki');
//$form =& $creator->create($wikipage);
// create the needed renderer
$renderer =& patForms::createRenderer("Array");
// set the renderer
$form->setRenderer($renderer);
// use auto-validation
$form->setAutoValidate('save');
// serialize the elements
$elements = $form->renderForm();
// ERROR DISPLAY ------------------------------------------------------
if ($form->isSubmitted()) {
    displayErrors($form);
    // see patExampleGen/customFunctions.php
}
// DISPLAY FORM ------------------------------------------------------
displayForm($form, $elements);
// see patExampleGen/customFunctions.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');
$tpl->addVar('form', 'start', $form->serializeStart());
$tpl->addVar('form', 'end', $form->serializeEnd());
$tpl->addRows('elements', $form->renderForm());
// this should be possible to be done in a more elegant way
if ($errors = $form->getValidationErrors()) {
    foreach ($errors as $field => $error) {