Data entry form: function, layout and validation (new user)
11 posts
• Page 1 of 1
Hello,
For starters, I am pleased to have found Dataface recently, as I am in the process of setting up a database for a large research project using MySQL. We need good data entry forms with client side validation, and so far it appears that Dataface will do the job superbly, especially since I have better things to do than learn more than a modicum of PHP. However, I have some questions that will probably expose my naivete in this venture, but I will appreciate any and all help. Basically, what I need are data entry forms that will allow data entry to multiple related tables at the same time. Our concerns are with speed of entry and accuracy of entries, as we would like to process 100 or more forms a day between 2 data entry guys working half time. I have found how to validate entries and will explore triggers. My specific questions are: How does one modify the layout of the form so that, rather than having 20 fields running N-S down the page (and having to scroll down), they are organized into a couple of columns on the page? i.e. field 1 _____________ field 2 ______________ How would one implement a spreadsheet-like entry field? I presume the widget type table does this, but can't find any documentation. But is this even a recommended way to enter data? Sure it is fast, but I can see more errors cropping up and how would validation be implemented? How would one specify a binary variable whose default is, say, 'False' using a check box? I.e. the field is basically something like, "Does the house not have a roof?" The default is F, but if checked, I want it to be T. So far I get '\0' entered into the database when I try to implement something. Sometimes I can imagine using checkboxes for a 'set' type variable with numerous options (e.g. 10). I tried to implement this, and get a long list running down the page. Not a very efficient use of screen real-estate in my opinion. How would I format the checkboxes so they ran horizontally across the page and wrapped? I don't know HTML, so didn't get far looking for the relevant atts call. That is all for the moment. I had more questions, but can't recall. Any help is much appreciated.
Currently no support for this. The next version (0. includes a number of features to make this easier, including a grid widget type to edit related records in a sort of spreadsheet format; inclusion of related fields directly in the edit form; addition of "transient" fields so that you can have fields on a form that are not directly bound to any database column, and hence allows you to handle the data using triggers. I don't plan to release 0.8 for a couple of months, so this doesn't help you yet. One way that you can enter data in multiple tables at once right now is using relationships. In a relationship, you can include fields from multiple tables, all of which would be editable on the "add new related record" form. How would one implement a spreadsheet-like entry field? Either a custom widget or custom action - but you'd have to be pretty good with PHP in order to do this.. if this is your first foray into PHP, i think this endeavor might be a bit much. I presume the widget type table does this, The table widget type sort of does this, but it is very limited - and I don't recommend using it. With this widget it will store all of the data as XML in a single column. How does one modify the layout of the form The current version unfortunately is not tremendously easy to customize for form layout. One way to do it would be to use CSS to assign absolute positions to all of the fields, to break them out of the html table that holds them. You can also do a little bit with overriding the templates in the dataface/Dataface/templates directory (anything with 'quickform' in the name of the template is probably related to this). 0.8, has reworked the entire form management architecture so that you would be able to override a single template to make this happen. -Steve
Steve,
Cheers. I appreciate the rapid reply. I will continue to learn how to use your app as I do feel it fits our needs, and I will look forward to version 0.8. I did find and implement the relationships feature. This works for the moment to enter related data to several tables. I was wondering, however, if there were some functions that might make entering data a bit more efficient: - is it possible, whereupon a user hits 'Save' for the first (parent) data form, they are immediately passed to the second related form? There they could then enter several data related to the first and then hit 'Done' or some equivalent and get passed to the 3rd form, etc.? - whether or not the above is feasible at this point, is it possible to implement a form of validation that essentially won't let the user logout or some-such until all the forms related to a record have been visited? - when using dataface, is it better to have the data write to a temporary table in the database and then integrate this into the main table after validation is complete? Or just go straight into the main tables? Thanks again. Steve S.
You can use after action triggers to accomplish this. Here is a sampling of posts and tutorials where you can read some more about these. http://framework.weblite.ca/forum/dataface-users/789695638/#43979773 http://framework.weblite.ca/documentation/how-to/after_action_triggers http://framework.weblite.ca/documentation/tutorial/submission_forms/sucess_page http://framework.weblite.ca/forum/dataface-users/701371472/#637778598
Currently there is no such support, however, since this is a good idea and it is simple to implement, I have just implemented a before_action_logout trigger in my dev version. You can modify your version to have such a trigger by editing the Dataface/AuthenticationTool.php file. Look for the following:
And add the following just before the session_destroy call:
So the section would now look like:
Then you can use the before_action_logout() trigger to test for certain criteria, and forward to a different page if the criteria is not met. e.g.
This is entirely up to you. It depends what behavior makes more sense for your application. There are many solutions to this problem, some more elegant than others. Best regards Steve
I can't get this to work right.
Basically, I want to click 'Save' for a new record and get taken to a form for entering a related record. I have tried setting up a trigger to do this, where the reference variable is 'house': function afterInsert(&$record){ $GLOBALS['ir'] =& $record; $ir =& $record; $hse = $ir->val('house'); //echo $hse; } function after_action_new(){ $app =& Dataface_Application::getInstance(); $auth =& Dataface_AuthenticationTool::getInstance(); $user =& $auth->getLoggedInUser(); $GLOBALS['ir']; $hse = $GLOBALS['ir']->val('house'); //echo $hse; if ( $user ){ // The user is not logged in so we forward to a success page. header('Location: index.php?-action=new_related_record&-table=house_characteristics&-house=$hse&-mode=list&-relationship=adult_mosquitoes'); exit; } } This sends me to an entry form for a related record, but not the right related record. It goes to the top of the list in the house_characteristics table. How do I get it to go to the right place? Thanks.
One thing that i notice from your code that won't work is the line: header('Location: because the string is in single quotes - so the $hse variable won't be resolved.. it will just get passed through as the literal string '$hse'. Not sure if this is the ultimate problem, but it can't be doing any good. -Steve
Nope, that doesn't do it.
I don't have a clue at this point how dataface finds its way around. By just clicking around, it appears that entries are referenced by 'cursor', which apparently derives from the position of an entry in the dataface list. There must be another way to navigate between individual entries based on information in them, field values. ???
Dataface references records by result sets.Ê If you don't give it a cursor, it will give you the first result in the result set. You can specify search parameters as GET parameters. E.g. index.php?-table=people&-firstname=steve specifies all users with "steve" in the first name. Adding an -action parameter, we can tell dataface what to do with the result set: index.php?-table=people&-firstname=steve&-action=edit will show the edit form to edit the first record in the result set. index.php?-table=people&-firstname=steve&-action=list will show all of the matching entries. Now, if you use the primary key as your search parameter, you can guarantee a result set of zero or one. -Steve
So I did this? and then I wrote the function I want (below). Now what do I do with it so that dataface will call it when one clicks logout?
Thanks. function before_action_logout(){ $app =& DataFace_Application::getInstance(); $auth =& Dataface_AuthenticationTool::getInstance(); $dbsel = $app->db(); $user =& $auth->getLoggedInUser(); $role = $user->val('Role'); if ( $role == 'EDIT' ) { $query1 = "SELECT count(*) from Houses"; $query2 = "Select count(distinct(house)) from Participants"; $res1 = mysql_query($query1,$dbsel); $res2 = mysql_query($query2,$dbsel); $n1 = mysql_result(res1,0); $n2 = mysql_result(res2,0); if ( $n1 != $n2 ) { header('Location: '.$app->url('-action=browse&-mode=list&-table=Participants').'&--msg='. urlencode('Sorry, you cannot logout. Participants are missing for some houses.')); exit; } exit; } }
11 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 32 guests |