Our powerful, but not yet released, form management package patForms got a lot of new features during the last week. On friday, I created a subpackage called patForms_Storage, which allows you to automatically store data in and retrieve data from various datasources without writing anything on your own. So far, I've implemented datastorages for CSV and
PEAR DB. You may specify a set of primary keys, so the storage container is able to determine whether the entry has to be updated or added. The code that you have to use looks like:
$storage = &patForms::createStorage( 'DB' );
$storage->setStorageLocation( 'mysql://pat:@localhost/pat', 'patForms_Storage' );
$storage->setPrimaryField( array( 'user', 'email' ) );
$storage->setFieldMap( array(
'user' => 'user',
'pass' => 'password',
'email' => 'email'
)
);
$form->setStorage( $storage );
You can easily combine this with another subpackage I've been working on: patForms_Creator, which builds forms for databases or anthing else. So you get your form that is connected to a database table within 5 minutes of work.
Another thing I've added are observers, that may be attached to the form or elements of the form. I'm using those to change attributes of the elements, actually I'm changing the CSS class of an element if an error occured.
To test patForms, get it from our
CVS or download a daily
snapshot. We'll soon publish some online examples, followed by an alpha version of patForms.