21 Posts
Roote
7 years ago
9
Topic

I have a multi-page form.  On stage 1 I have a input text field that is needed on stage 2 to query a table and prefill some input text fields.  I used the tip below, but not sure how to make it work with LIVE sql.  I tried calling the field in Live sql, but it doesn't work.  I also thought about passing the field in the URL and tried using the Form Action plugin and setting the action to GET, but it keeps redirecting to the index page no matter what I use as the target.  Any help would be appreciated. 

https://www.seblod.com/resources/tutorials/how-to-pass-a-value-between-stages-in-multistage-form

Get a VIP membership
1283 Posts
Bucklash
7 years ago
0
Level 1

Hi

a quick answer from, not necessarily a solution....

LIVE applies only apply when content isNew. ie $config['isNew'] = 1.

Once you go to stage 2 from stage 1 your content is no longer new, you are now editing existing content. ie $config['isNew'] = 0

If passing value to URL didn't work for you then I might do db query using beforerender and prefix fields that way

4229 Posts
Kadministrator
7 years ago
0
Level 1

Fields on different stages are sill on the same form, you can't change url calues between them. Unfortunatelly I don't have a direct solution for your problem as there is no way to pass a value from another form field from same form to live sql field.You will need to use code fields and do your query there as Bucklash suggested.

21 Posts
Roote
7 years ago
0
Level 1

Ok, thank you for the help.

21 Posts
Roote
7 years ago
2
Level 1

Thanks for the help again Bucklash and Klas.  One last question about the solution.  Say I query the information in a BeforeRender process field.  How do i prefill the fields with the resultset.  In PHP I would simply set the value of the input field with something like <?php echo $row['Data_Field'];?> .  Can this be done when setting the field values?

1283 Posts
Bucklash
7 years ago
1
Level 2

Hi Roote

Depending on where you are within Seblod you have access to arrays $fields, or $cck, plus $config.

var_dump($fields) and have a look.

For beforeRender in forms you could try to use:

  1. $fields['art_title']->form, and 
  2. $fields['art_title']->value...

I am no expert, but I think it depends on the field as to whether 'form' or 'value' work best, maybe both... might depend on which way the wind is blowing, not sussed it out yet.

1283 Posts
Bucklash
7 years ago
0
Level 3

Hi Roote

Not sure if this is relevant in your case, but you could have duplicate fields...

In the first stage get all your live data established, and then in the next stage those duplicated fields will contain the correct data to base any calculations from

21 Posts
Roote
7 years ago
2
Level 1

Bucklash,

Just for clarification: In the first stage I require they enter an ID.  Also on Stage 1 I have a BeforeStore  where there is an ID check.  If their ID is found in the DB I allow the save and to continue to the 2nd stage.  On the Stage 2 I would pre-populate the fields(visible and editable) using their ID from Stage 1.  

As for you first tip, I'll give it a shot. 

1283 Posts
Bucklash
7 years ago
1
Level 2

Hi

More thoughts...

Have you tried ajax validation on the ID field?

It does exactly what you are trying to do.  

Also, and not relevant to your case:

Instead of Stage, have form split up as slides in a slideshow.  I did that and it worked nice.  

Less hassle for me as I didn't have to do funky stage stuff 

21 Posts
Roote
7 years ago
0
Level 3

Didn't think of that Bucklash, but I'm pretty new to Seblod so any advice is great.

Get a VIP membership