Create a "View" for data-input?

A place for users and developers of the Xataface to discuss and receive support.

Create a "View" for data-input?

Postby ppuschmann » Fri Feb 20, 2009 8:19 am

Hi,

I want some users to create some datasets in my DB.

Now I have a big table (many columns), and I need these columns, but I want a user just only to see a small amount of the columns while typing.

My thought:
I create a "view" called "producttype1" and the coulumns 1 to 5 are displayed.
A second "view" calles "producttype2" can only input data into the columns with even numbers (just an example).

Is there a solution?
ppuschmann
 
Posts: 6
Joined: Fri Feb 20, 2009 7:15 am

Postby shannah » Fri Feb 20, 2009 10:02 am

This should work. But you would be treating your views as separate tables, with their own configuration directories (i.e. fields.ini file etc..). If you do use a view, make sure that you tell Xataface which fields comprise your primary key (it can't figure this out automatically like it can with regular tables). You would do this by adding the following directives to the fields that are part of the primary key in the fields.ini file:
Code: Select all
Key=PRI


E.g. if your primary key is 'record_id':
Code: Select all
[record_id]
    Key=PRI
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby ppuschmann » Mon Feb 23, 2009 12:45 am

Thank you for your reply, but I think I was missunterstood.

Well, I don't actually want to use real views (in databases) but I want to have different input forms.

Input-Form1:
Show columns 1-5

Input -Form2:
Show columns 1,4,5,7-12

Why I want to do this?

The user (who is filing the records) shall now be distracted by the other columns (that he eventually has to skip each time).

He only shall be able to enter the data that fitts to the specific type of article (artikel) that he enters.

Paul
ppuschmann
 
Posts: 6
Joined: Fri Feb 20, 2009 7:15 am

Postby shannah » Mon Feb 23, 2009 7:18 pm

Hmmm... lots of ways to skin this cat. But none that is perfect. I believe that the best way is to either use the 'tab' or the 'group' directive to split fields into tabs or groups.

You can specify that a group is collapsed by default, and you can link directly to a specific "tab" of the edit form.

You could also programmatically change the widget types of fields - but this starts to get a little messy.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby ppuschmann » Thu Feb 26, 2009 12:42 am

Hi Steve,

thank you for your answer.

The Problem: There are columns that will show up in every "tab" / "group".

I will give it a try.

Paul
ppuschmann
 
Posts: 6
Joined: Fri Feb 20, 2009 7:15 am

Postby shannah » Thu Feb 26, 2009 8:38 am

There is another option. You could create a custom action for each type of form you want.

The df_create_edit_record_form and df_create_new_record_form functions allow you to create a form with a subset of the fields from a table.

E.g.

Code: Select all
$form =& df_create_new_record_form('people', array('FirstName','LastName'));
if ( $form->validate() ){
    $res = $form->process(array(&$form, 'save'), true);
    if ( PEAR::isError($res) ) return $res;
    header("Location: ".DATAFACE_SITE_HREF.'?--msg='.urlencode('Record added'));
    exit;
}

$form->display();


This example would create a new record form for the people table with only the FirstName and LastName fields.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 3 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved