Get a form value in the heading of that form

Status
Not open for further replies.

Mikmac

New Member
I would like to get in a form heading one of the values from that form. Not on the fly but after the form has been processed and when you go back to view the form. I tried this in the form template:
Code:
<?php $month = $aData['jos_fabrik_formdata_19___check_month'];?>
<h1>Checksheet <?php echo $month;?></h1>
But only the maintitle "Checksheet" shows up. Not the added value from 'jos_fabrik_formdata_19___check_month'. Suggestions?

Thanks again
 
do

<pre><?php print_r($aData);?></pre>

to see if there is anything in $aData.
Its been too long since I looked at 1.0.x to be able to tell you more, but I'm dubious that $aData actaully contains anything
 
I'm 99% sure $aData[] is only used on the submission side, not form rendering.

During rendering, all element data is in the $this->groups[x] array.

So try var_dump($this->groups) ... or print_r, your choice.

-- hugh
 
That helps. $aData is indeed empty. $this-> contains all the data.

I just can't figure out how to extract one element from the array.

for example my array looks like this (result from print_r):
Code:
Array
(
    [Checksheet] => stdClass Object
        (
            [canRepeat] => 0
            [addJs] => 
            [delJs] => 
            [showGroup] => 1
            [css] => 
            [id] => 63
            [title] => Details
            [name] => Checksheet
            [delId] => 
            [addId] => 
            [displaystate] => 0
            [elements] => Array
            (
                    [jos_fabrik_formdata_19___cs_join] => elementTmpl Object
                        (
                            [id] => jos_fabrik_formdata_19___cs_join
                            [int] => 578
                            [label] => Building
                            [error] => 
                            [divclass] => fb_element
                            [hovertext] => 
                            [element] => BWOF40 WINZ Building
                            [value] => BWOF40 WINZ Building
                            [hidden] => 0
                        )
etc.

Can I call the value of one element?
Tried
Code:
$this->groups[jos_fabrik_formdata_19___cs_join]; or
$this->groups->elements[jos_fabrik_formdata_19___cs_join];
and many more, with or without single or double quotes, with no luck so far.

This would help me with another issue as well, your answer is much appreciated!
 
Basically ...

If the var_dump/print_r says it's an object, then it uses foo->bar, if it's an array, it uses foo['bar'] .... so in this case, $groups itself is an array, and 'checksheet' is the first thing in the array, so it's be $groups['checksheet'].

The checksheet is then an object, and you want the elements within that ...

The elements within $groups['checksheet'] is then an array, so to get at your element, it'd then be ...

$groups['checksheet']->elements['jos_fabrik_formdata_19___cs_join']

... and finally, that element itself is an object, so to get at (say) the label is ...

$groups['checksheet']->elements['jos_fabrik_formdata_19___cs_join']->label;

Sounds a lot more complex than it is. But just remember, object use ->, arrays use [], and you'll be OK. And when in doubt, var_dump/print_r the whole thing, and work it out from that.

-- hugh
 
Thanks hugh, this is clear and got it all to work. Note for other users that the objects are case sensitive too, it took me some time to find out that 'checksheet' had to be 'Checksheet' to make it work.

I am gone ask my client now to do a small extra donation to you for all help and support.

Closing this thread.
 
Oh yeah, I should have mentioned that. PHP is case sensitive, period. So variable name, array indexes and object names are all case sensitive.

So ...

$thisVar is different to $thisvar.
$foo['thisVar'] is different to $foo['thisvar']
$foo->thisVar is different to $foo->thisvar

Any donation would obviously be gratefuly received, but as an existing supporter, don't feel obliged.

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

Thank you.

Members online

No members online now.
Back
Top