I have a form with an array (nombre[]) that expands fine and shows the arrary of names (nombres, in Spanish), comma separated,, comma separated, in the email that's sent (from the email template) but shows the word "Array" instead where the field {nombre} is placed in the "On Submit code - after sending email:" section.
A bug? or should I be manually (that is to say, with PHP) collapsing the array before the "On Submit code - after sending email:" portion? At the moment my email template and "On Submit code - After" are identical HTML code so I would have expected them to produce the same results.
Edit:
It doesn't put the `nombre´ array/field into the DB either so there's obviously something I have to do. Just need to figure out what.
Note: Chronoforms _is_ handling my posted arrays.
Ah well, I have all night to figure it out.
A bug? or should I be manually (that is to say, with PHP) collapsing the array before the "On Submit code - after sending email:" portion? At the moment my email template and "On Submit code - After" are identical HTML code so I would have expected them to produce the same results.
Edit:
It doesn't put the `nombre´ array/field into the DB either so there's obviously something I have to do. Just need to figure out what.
Note: Chronoforms _is_ handling my posted arrays.
Ah well, I have all night to figure it out.
Hi willson,
I think I'm right in saying that the {fieldname} syntax is only good in the email template - but I could be wrong.
Use
Bob
PS If that gives an error message then it should probably be implode instead of explode.
I think I'm right in saying that the {fieldname} syntax is only good in the email template - but I could be wrong.
Use
<?
$nombres = JRequest::getVar('nombres', '', 'post);
$nombres = explode(', ', $nombres);
echo $nombres;
?>
Bob
PS If that gives an error message then it should probably be implode instead of explode.
Hey, don't you ever rest? Long days.
The {fieldname} has been working in the "onsubmit code - after" for me (just lucky I guess) on quite a number of forms. I use it to present a confirmation page to the user.
I see.. it's explode, not expand. Or, wait, I want to collapse it down to a single string to load the db so I guess it's implode (not collapse).
Note: I do have access to the PHP documentation (http://es2.php.net/manual) but couldn't figure out why this was acting differently between the email, submit-after and the db.
Hmm... come to think of it, I might have to implode it before the autogenerated code to get it to load the db - - 'cause the field is currently coming up empty there. So, I've got three behaviours to understand. 1) email: arrary shows up comma separated (good), submit-after: the word "Array" (bad) 3) db: empty field (mysterious).
I'll get it figured out. Thanks.
The {fieldname} has been working in the "onsubmit code - after" for me (just lucky I guess) on quite a number of forms. I use it to present a confirmation page to the user.
I see.. it's explode, not expand. Or, wait, I want to collapse it down to a single string to load the db so I guess it's implode (not collapse).
Note: I do have access to the PHP documentation (http://es2.php.net/manual) but couldn't figure out why this was acting differently between the email, submit-after and the db.
Hmm... come to think of it, I might have to implode it before the autogenerated code to get it to load the db - - 'cause the field is currently coming up empty there. So, I've got three behaviours to understand. 1) email: arrary shows up comma separated (good), submit-after: the word "Array" (bad) 3) db: empty field (mysterious).
I'll get it figured out. Thanks.
Hi willson,
No rest for the wicked . . . nor any time to be wicked ?-)
There's an option - on the Autogenerated Tab I think - to let ChronoFoms try to handle array values - this might help.
Bob
No rest for the wicked . . . nor any time to be wicked ?-)
There's an option - on the Autogenerated Tab I think - to let ChronoFoms try to handle array values - this might help.
Bob
Yup, it was implode
has got into the text in the conformation page.
Now, on to getting it into the db; which continues to not write the array/value.
<?php
$nombre = JRequest::getVar("nombre", '', "POST");
$nombre = implode(', ', $nombre);
echo $nombre;
?>
has got into the text in the conformation page.
Now, on to getting it into the db; which continues to not write the array/value.
Hi willson,
this is a bug, try this :
cheers
Max
this is a bug, try this :
<?php
$nombre = JRequest::getVar("nombre", '', "POST");
JRequest::setVar("nombre", implode(', ', $nombre));
echo JRequest::getVar("nombre", '', "POST");
?>
cheers
Max
Once I knew it was an implode challenge I browsed around and found some mention of this symptom in the Bugs forum but had not yet quite figured out how to attack it.
What I did, with your help and my own twist, was add
to the On Submit code - before sending email so that the array is imploded first;
then I used the field name {nombre} as usual in the email template and the confirmation page (for which I use `On Submit-after´)
and since the post array value for nombre was now a simple field it also loaded into the database as expected. Thus, a certain degree of success.
The client might not like having multiple nombres all stuffed into one field but I'll find a way to deal with that separately. I'm thinking of php to take the original nombre array and setvar it into the post array as fields named nombre[1], nombre[2] and so on; which I would have created as hidden fields in the form (I'm thinking of using square brackets in the field names to remind me that it was an array but that might lead to problems later with parsing so perhaps an underscore would be better) . I know there's a maximum number of nombres I'll get so it's not too cumbersome an approach. Since there will be a number of fields for nombre[n] the default Chronforms will take care of getting it into the db as usual and I'll have the individual names each in their own field as well as imploded in the main nombre field. Win-win.
Thanks all.
What I did, with your help and my own twist, was add
<?php
$nombre = JRequest::getVar("nombre", '', "POST");
JRequest::setVar("nombre", implode(', ', $nombre));
?>
to the On Submit code - before sending email so that the array is imploded first;
then I used the field name {nombre} as usual in the email template and the confirmation page (for which I use `On Submit-after´)
and since the post array value for nombre was now a simple field it also loaded into the database as expected. Thus, a certain degree of success.
The client might not like having multiple nombres all stuffed into one field but I'll find a way to deal with that separately. I'm thinking of php to take the original nombre array and setvar it into the post array as fields named nombre[1], nombre[2] and so on; which I would have created as hidden fields in the form (I'm thinking of using square brackets in the field names to remind me that it was an array but that might lead to problems later with parsing so perhaps an underscore would be better) . I know there's a maximum number of nombres I'll get so it's not too cumbersome an approach. Since there will be a number of fields for nombre[n] the default Chronforms will take care of getting it into the db as usual and I'll have the individual names each in their own field as well as imploded in the main nombre field. Win-win.
Thanks all.
This topic is locked and no more replies can be posted.