Page 1 of 1

PostPosted: Mon Oct 23, 2006 9:48 am
by roginald
Is there a way to utilize the api to create an input form that addressed multiple tables and their relationships easily? I was thinking of this as I was about to write an input form on the front end of an application that is currently utilizing a dataface back end...any help would be greatly appreciated...and since I haven't mentioned it yet, thank you for a stellar application.

roginald

PostPosted: Tue Oct 24, 2006 9:45 am
by alanslleung
Okay... this depends on what type of form you need to create, and what you consider "easy".

The "easiest" way to do this might be to create a relationship with all of the appropriate fields. Then you can use the df_create_new_related_record_form() function which generates a Dataface_ShortRelatedRecordForm object which is the same form used when adding new records in a relationship.

You can make it so that this relationship does not show up in your tabs by setting the action:visible property of the relationship to 0.

e.g.:

Code: Select all
$profile =& df_get_record('Profiles',array('id'=>10));
$form =& df_create_new_related_record_form($profile, 'Publications');

if ( $form->validate() ){
    $res = $form->process(array(&$form, 'save'), true);
    if ( PEAR::isError($res) ) {
        // There was an error in processing... do something.
    } else {
        // It was successful.. forward to a success page.
    }
}

$form->display();