Using a combination of checkbox arrays, there is no problem with multiple checked boxes outside of the multiplier posting info. in an email. Unfortunately, I'm experiencing a problem with multiple selected checkboxes inside the Multiplier. The only thing that posts from the Multiplier is the textbox data. No checkbox data. Obviously I'm not familiar with how checkbox arrays in a Multiplier are to post.
I have a 'Handle Arrays' action before the email action to handle the checkbox array data outside of the Multiplier, after the 'Custom code' action that is to handle the multiplier data.
The attachment gives details of the debugger and an error that appears with 'Undefined index:' and 'Array to string conversion' error.
[attachment=0]multiplier-data-issue.pdf[/attachment]
I have a 'Handle Arrays' action before the email action to handle the checkbox array data outside of the Multiplier, after the 'Custom code' action that is to handle the multiplier data.
The attachment gives details of the debugger and an error that appears with 'Undefined index:' and 'Array to string conversion' error.
[attachment=0]multiplier-data-issue.pdf[/attachment]
Hi toad,
I don't see any sign of multiplier output in the pdf you posted. Where should I be looking?
Bob
I don't see any sign of multiplier output in the pdf you posted. Where should I be looking?
Bob
Thank you for getting back to me.
I've attached the highlighted areas of the multiplier session I'm trying to acquire and also provided extra screenshots of settings. Please let me know if I've missed anything.
[attachment=2]multiplier-data-front-end.PNG[/attachment]
[attachment=3]multiplier-data-back-end.PNG[/attachment]
[attachment=5]events.PNG[/attachment]
[attachment=4]multiplier-data-custom-code.PNG[/attachment]
[attachment=0]multiplier-issue-data-array.gif[/attachment]
[attachment=1]debug-info.gif[/attachment]
I've attached the highlighted areas of the multiplier session I'm trying to acquire and also provided extra screenshots of settings. Please let me know if I've missed anything.
[attachment=2]multiplier-data-front-end.PNG[/attachment]
[attachment=3]multiplier-data-back-end.PNG[/attachment]
[attachment=5]events.PNG[/attachment]
[attachment=4]multiplier-data-custom-code.PNG[/attachment]
[attachment=0]multiplier-issue-data-array.gif[/attachment]
[attachment=1]debug-info.gif[/attachment]
Update:
I went into design view and added [] to the checkbox groups in the Multiplier. The arrays are being created, but not posting in the email because I'm still having trouble converting the arrays to strings.
I went into design view and added [] to the checkbox groups in the Multiplier. The arrays are being created, but not posting in the email because I'm still having trouble converting the arrays to strings.
Mr. Greyhead,
I have made
Screenshots attached for reference:
[attachment=0]custom-code.PNG[/attachment]
[attachment=1]designer.PNG[/attachment]
[attachment=2]email-code.PNG[/attachment]
Results after sending form:
Notice: Array to string conversion on line 5
Line 5 is
[attachment=4]array.gif[/attachment]
[attachment=4]debug.gif[/attachment]
I hope you can still assist me.
Thank you.
I have made
This is private content
of the page, in hopes you can further assist me.Screenshots attached for reference:
[attachment=0]custom-code.PNG[/attachment]
[attachment=1]designer.PNG[/attachment]
[attachment=2]email-code.PNG[/attachment]
Results after sending form:
Notice: Array to string conversion on line 5
Line 5 is
$session[] = "<tr><td>{$s['schoosedayM']}</td></tr><tr><td>{$s['sxcareM']}
[attachment=4]array.gif[/attachment]
[attachment=4]debug.gif[/attachment]
I hope you can still assist me.
Thank you.
Hi toad,
As you can see from the Debugger output your $s['schoosedayM'] is an array* if you want to display this sensibly then you will need to implode it into a comma separated string e.g. implode(', ', $s['schoosedayM'])
Bob
* Its not clear to me that checkboxes make sense here - should these be radio buttons with only one choice allowed?
As you can see from the Debugger output your $s['schoosedayM'] is an array* if you want to display this sensibly then you will need to implode it into a comma separated string e.g. implode(', ', $s['schoosedayM'])
Bob
* Its not clear to me that checkboxes make sense here - should these be radio buttons with only one choice allowed?
implode(', ', $s['schoosedayM'])
Looking at the Custom code I'm using, the
$form->data['session_data'] = implode("\n", $session);
wouldn't already implode it, but on new lines instead of a comma separated value? The reason why I'm asking is that it won't be just checkbox group data, I will also have text box data and radio button data. From what I'm researching, I'm wondering if I'm going to have to have two different {session_data} 'implode' processes? One for the checkbox group data and the other for everything else? Or do I have to break down each 'schoosedayM' within the $session[] = "...." because I will not only have 'schoosedayM', I will also have 'schoosedayT', 'schoosedayW', and others. So then inside the $session[], would it be wiser for me to use implode{",", $session) within it? Or am I going to have to go in some other direction.
Like:
$form->data['session_data'] = implode("\n", $session); (for regular data--text box, textarea, radio)
$form->data['session_data'] = implode{",", $session); (for checkbox group array)
Maybe I'm making a bigger deal out of this, but I'm trying to figure out a way to process all data that will include radio, textarea, textbox and checkbox group.
Its not clear to me that checkboxes make sense here - should these be radio buttons with only one choice allowed?
I don't disagree with you, Mr. Greyhead. In fact, I fought to use radios because it made more sense for the cause. Unfortunately, I lost this battle.
Hi toad,
Sure, imploding $session with new lines is fine . . . PROVIDED that $session is an array of strings. It has nothing to do with your checkbox values though - you have to convert those to strings first.
Bob
Sure, imploding $session with new lines is fine . . . PROVIDED that $session is an array of strings. It has nothing to do with your checkbox values though - you have to convert those to strings first.
Bob
So I'm trying two different methods of solutions here:
Which displays Parse error: syntax error, unexpected ',' on line 5. Line 5 being the $session[] line.
I've also tried:
Which brings me halfway to my goal.
When I select the 'schoosedayM' values AND the 'sxcareM' values, I still get Notice: Array to string conversion on line 5 error, and only 'sxcareM' values display within the email template, not both the 'schoosedayM' values and 'sxcareM':
So now how do I get all of the needed values to play nice and post?
<?php
if ( !empty($form->data['student']) && is_array($form->data['student'] ) ) {
$session = array();
foreach ( $form->data['student'] as $s ) {
$session[] = "<tr><td>{(implode(",", $s['schoosedayM'])}</td></tr><tr><td>{(implode(",", $s['sxcareM'])}</td></tr>";
}
}
Which displays Parse error: syntax error, unexpected ',' on line 5. Line 5 being the $session[] line.
I've also tried:
<?php
if ( !empty($form->data['student']) && is_array($form->data['student'] ) ) {
$session = array();
foreach ( $form->data['student'] as $s ) {
$session[] = "<tr><td>{$s['schoosedayM']}</td></tr><tr><td>{$s['sxcareM']}</td></tr>";
}
}
$form->data['session_data'] = implode("\n", $session);
$form->data['session_data'] = implode(',', $s['schoosedayM']);
$form->data['session_data'] = implode(',', $s['sxcareM']);
?>
Which brings me halfway to my goal.
When I select the 'schoosedayM' values AND the 'sxcareM' values, I still get Notice: Array to string conversion on line 5 error, and only 'sxcareM' values display within the email template, not both the 'schoosedayM' values and 'sxcareM':
[student] => Array
(
[1] => Array
(
[schoosedayM] => Array
(
[0] => Full Day
[1] => Half Day (AM)
)
[sxcareM] => Array
(
[0] => 8 to 9 AM
[1] => 12 to 1 PM
[2] => 4 to 5:30 PM
[3] => None
)
)
)
<table>
8 to 9 AM,12 to 1 PM,4 to 5:30 PM,None
</table><br /><br />
So now how do I get all of the needed values to play nice and post?
Hi toad,
This is bad PHP
You can only use the {$var_name} syntax for variables that start with $
Bob
[[>> Later : removed duplicated implode . . . see later post <<]]
This is bad PHP
$session[] = "<tr><td>{(implode(",", $s['schoosedayM'])}</td></tr><tr><td>{(implode(",", $s['sxcareM'])}</td></tr>";
You can't put {(implode(",", $s['schoosedayM'])} in the middle of a string. EITHER implode those strings first:$schoosedayM = implode(",", $s['schoosedayM']);
then you can use[code". . .]<td>{$schoosedayM} . . .[/code]OR use the quotes like this"<td>".implode(",", $s['schoosedayM'])." . . .
You can only use the {$var_name} syntax for variables that start with $
Bob
[[>> Later : removed duplicated implode . . . see later post <<]]
Okay, I've made a slight modification to the code you supplied (you repeated the 'implode' part):
This seems to work well. I'm going to apply it with the rest of the form to see how it pans out. I'll be replying this afternoon.
Thank you!
<?php
if ( !empty($form->data['student']) && is_array($form->data['student'] ) ) {
$session = array();
foreach ( $form->data['student'] as $s ) {
$session[] = "<tr><td>".implode(",", $s['schoosedayM'])."</td></tr><tr><td>".implode(",", $s['sxcareM'])."</td></tr>";
}
}
$form->data['session_data'] = implode("\n", $session);
?>
This seems to work well. I'm going to apply it with the rest of the form to see how it pans out. I'll be replying this afternoon.
Thank you!
Okay, so the form works. For the most part.
But if no additional students are added, I get the:
Notice: Undefined variable: session on line 11 and Warning: implode(): Invalid arguments passed on line 11.
I assume that I need to add something like:
if ( !empty($form->data['student']) && is_array($form->data['student'] ) ) {
$session = array();
foreach ( $form->data['student'] as $s ) {
if ( !empty($s['schoosedayM']) && is_array($s['schoosedayM'] ) ) {
foreach ( $s['schoosedayM'] as $value_string ) {...
to get rid of the error. The additional student fields are not required and the default checked option is 'None'. So I'm not sure why it posts the error.
But if no additional students are added, I get the:
Notice: Undefined variable: session on line 11 and Warning: implode(): Invalid arguments passed on line 11.
I assume that I need to add something like:
if ( !empty($form->data['student']) && is_array($form->data['student'] ) ) {
$session = array();
foreach ( $form->data['student'] as $s ) {
if ( !empty($s['schoosedayM']) && is_array($s['schoosedayM'] ) ) {
foreach ( $s['schoosedayM'] as $value_string ) {...
to get rid of the error. The additional student fields are not required and the default checked option is 'None'. So I'm not sure why it posts the error.
I wound up just setting Error Reporting to 'None' to remove the error message. Otherwise, the information is posting as it should.
Thank you, Mr. GreyHead, for devoting your assistance in helping me.
Thank you, Mr. GreyHead, for devoting your assistance in helping me.
Hi toad,
Yes you are correct - to remove the PHP Notices you would need to check that the data exists before using it. But the approach of turning the Error reporting down to ignore Notices is fine.
Bob
Yes you are correct - to remove the PHP Notices you would need to check that the data exists before using it. But the approach of turning the Error reporting down to ignore Notices is fine.
Bob
This topic is locked and no more replies can be posted.