Forms across multiple pages

Status
Not open for further replies.

cookn22

Active Member
I've made leaps and bounds with my fabrik know-how in the past couple weeks, but I'm still a newb, so bear with me...

Here's what I've been working on, which hasn't really worked...at all, but going through it may give someone an idea of what I'm trying to do:

I have two tables in the MySQL db, lets call them client_demographics and client_info. Each has an element "id". On the first form you enter in the fields for client_demographics and hit submit. (the client_demographics id is set to autoincrement). The jump page is set to the form for client_info. You fill in those fields and hit submit. Hopefully, the id for the client_info form is autofilled in with the id from the client_demographics form. The ideal outcome is a new entry in both the client_demographics and client_info tables that share the same id.

Now, I've been able to sort of get this to sort-of work by putting &rowid={id} in the jump url for the client_demographics form, and then have

Code:
$name = $GLOBALS[_REQUEST][rowid];
return "$name";

for the default value of the id element of client_info and checking 'eval'. But this doesn't really work, since for some reason it won't put the rowid in to the value for client_info___id unless I refresh the page, so that's no good.

I know that joins are probably the answer to this somehow, but I haven't been able to figure out how to use them correctly, especially with this problem...

Any help or suggestions would be appreciated! I'm betting this is a common thing to do that I'm making extraordinarily difficult for myself...
 
Try doing it with a table join. Just join your second table to your first table, and all the groups should show show up on the first form. No need for chained forms. When you save the main form, it'll automatically create / edit that second table row.

-- hugh
 
I kinda wanted it on two separate pages, but if that's not easily done then I'll go the one-page route.
 
Daisy chaining forms can be done, and there's been some discussions recently about it, but I can't seem to track them down. And I can't remember the magic incantations off the top of my head.

I'll talk to Rob when he wakes up (the problems of 7 hour time zone differences!).

-- hugh
 
hi

the principal of what your doing seems pretty solid.
Try accessing the session data, rather than appending the data to the url:

Code:
global $_SESSION;
$key = 'jos_fabrik_formdata_1___name';
return $_SESSION["fabrik"][1][$key];
 
Rob Clayburn said:
hi

the principal of what your doing seems pretty solid.
Try accessing the session data, rather than appending the data to the url:

Code:
global $_SESSION;
$key = 'jos_fabrik_formdata_1___name';
return $_SESSION["fabrik"][1][$key];

Aren't the key names that look like 'jos_fabrik_formdata_1___name' only there when you let Fabrik make your forms/tables/elements for you? I've been kind of confused about this for awhile.

I've started with another test page to try and figure this problem out, but using different tables this time (for no particular reason). The concept is the same as before... This time there's a form called School with school_id as its autoincrementing primary key. When the School form is submitted it jumps to a form called Student, which has a field called school_id which I want to autofill with the id from the previous form. Student it also has its own autoincrementing primary key called student_id. Basically the same situation I outlined in my first post.

Ok! On to the question:

When I do a <pre> <?php print_r($_SESSION); ?> </pre> in the jumped-to form (Student, from School) like I've described above, it prints out this:
Code:
Array
(
  [tableLimitLength{com_fabrik}{1}] => 30
  [tableLimitStart{com_fabrik}{1}] => 0
  [tableLimitLength{com_fabrik}{2}] => 30
  [tableLimitStart{com_fabrik}{2}] => 0
  [fabrik] => Array
    (
      [1] => Array
        (
          [school_id] => Array
            (
              [type] => 
              [value] => 
              [match] => 
            )

          [school_name] => Array
            (
              [type] => 
              [value] => Homewood
              [match] => 
            )

          [school_principle] => Array
            (
              [type] => 
              [value] => who+knows
              [match] => 
            )

          [_cursor] => Array
            (
              [type] => 
              [value] => 0
              [match] => 
            )

          [_total] => Array
            (
              [type] => 
              [value] => 0
              [match] => 
            )

          [returntoform] => Array
            (
              [type] => 
              [value] => 0
              [match] => 
            )

          [_referrer] => Array
            (
              [type] => 
              [value] => http%3A%2F%2Fwww.uab.edu%2Fuabsap%2Fcourtdb2%2Findex.php%3Foption%3Dcom_fabrik%26Itemid%3D106
              [match] => 
            )

          [School.school_id] => Array
            (
              [type] => 
              [value] => 4
              [match] => 
            )

        )

    )

)

Ok, so for some reason, school_id doesn't have the value in it, but there's School.school_id at the end of the array, which does have the right value in it. I can't really figure out why School.school_id is there at all, but it has the value in it, so that's good. Unfortunately, there's a a period in the key, and I don't know how to access array values when there are periods (concantenation operators) in the key. How do I get around this to get the value from the session?
 
Yes, it only uses the fabrik_formdata_X name for tables Fabrik creates. Rob was just using that as an example.

I think it's pre-pending the table name to the school_id because that's the primary key on a non-Fabrik table. If its a Fabrik table, we know what the primary key is because its always called fabrik_internal_id. But when processing the form, we prepend table names to primary keys there may be any doubt about the table name of. So by the time the session data gets written, we've already changed that name. Something like that, anyway.

Having the . shouldn't make any difference once quoted, so ...

Code:
$_SESSION["fabrik"][1]['School.school_id'];
should get it.

-- hugh
 
Actually..I'm still having problems. I can't get the default values to load into the element on the jumped-to form without having to refresh the page first. It doesn't matter whether its a $_SESSION value or just a plain number, it won't appear in the field without refreshing the page first. Any ideas?
 
try

global $_SESSION;
return $_SESSION['fabrik'][1]['School.school_id']['value'];
 
slight edit

global $_SESSION;
return urldecode($_SESSION['fabrik'][362]['name']['value']);
 
I think we are still missing a urldecode() somewhere in our code, BTW. I'm still occasionally seeing issues with "foo+bar+garply" and stuff like that when using jump pages and session data.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top