Form fields in custom form

22 posts by 3 authors in: Forums > CMS Builder
Last Post: August 21, 2014   (RSS)

By design9 - July 30, 2014

Attached! Thanks!

Attachments:

freeform1.php 23K

By claire - July 30, 2014

Okay, change the line to this:

$days_TSV = "\t" . implode("\t", @$_REQUEST['days'] ) . "\t";

The form will ignore it if it isn't checked.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - July 31, 2014

You'll have to change the code to check if it's set then. Add this:

if(isset($_REQUEST['days']) {
    $days_TSV = "\t" . implode("\t", $_REQUEST['days'] ) . "\t";
}
else {
    $days_TSV = "";
}

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By design9 - July 31, 2014

Perfect!

Thanks for all your help!

By design9 - August 14, 2014

Claire,

I one other thing I need help with. With the coding above that we used to output the days of week which is a multiple list with checkbox. It works perfect to record the data in backend of CMS. However, when I put the

<?= @$_REQUEST['days']?>

in my preview file, it just outputs array. It also does the same for the email template (#days#) that is sent to user and admin:

'days'            => $_REQUEST['days'],

Is there a way to make that data display properly in the preview file and email template? I have uploaded my file as well in case you need to look at everything.

Here is my coding for the checkbox:

<div id="days" >
<div class="form-label">Days of Week:</div>
<div class="form-field">

<fieldset>
<?php foreach($days_dirRecords as $record): ?>
<input type="checkbox" value="<?php echo $record['habbit']; ?>" <?php echo checkIfInArray($record['habbit'], @$_REQUEST["days"]) ?> name="days[]" />&nbsp;<?php echo $record['habbit']; ?>
<br />
<?php endforeach; ?>
</fieldset>



</div></div>

Thanks! April

Attachments:

form.php 27K

By design9 - August 15, 2014

Claire,

I one other thing I need help with. With the coding above that we used to output the days of week which is a multiple list with checkbox. It works perfect to record the data in backend of CMS. However, when I put the

<?= @$_REQUEST['days']?>

in my preview file, it just outputs array. It also does the same for the email template (#days#) that is sent to user and admin:

'days'            => $_REQUEST['days'],

Is there a way to make that data display properly in the preview file and email template? I have uploaded my file as well in case you need to look at everything.

Here is my coding for the checkbox:

<div id="days" >
<div class="form-label">Days of Week:</div>
<div class="form-field">

<fieldset>
<?php foreach($days_dirRecords as $record): ?>
<input type="checkbox" value="<?php echo $record['habbit']; ?>" <?php echo checkIfInArray($record['habbit'], @$_REQUEST["days"]) ?> name="days[]" />&nbsp;<?php echo $record['habbit']; ?>
<br />
<?php endforeach; ?>
</fieldset>



</div></div>

Thanks! April

Attachments:

form.php 43K

By claire - August 15, 2014

Hi April

The days of the week are in an array, and you can't echo arrays without doing a little preparation first.

Try something like this: 

implode(', ',$_REQUEST['days'])

in order to show the array as a string of characters. What it should do is combine all the array elements into a single string separated by commas.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By design9 - August 20, 2014

Claire,

I used this and it worked perfectly to output text in my email template.

However, then when I went back to submit my form again, I got the following error where this code is located.

'days'             => implode(', ',$_REQUEST['days']),

Notice: Undefined index: days in C:\inetpub\charlotteparent\directory\forms\form.php on line 293 Warning: implode(): Invalid arguments passed in C:\inetpub\charlotteparent\directory\forms\form.php on line 293

Is it conflicting with the main code we placed to make days of week work or if there an easy to fix?

// setup checkbox days
 if(isset($_REQUEST['days'])) {
    $days_TSV = "\t" . implode("\t", $_REQUEST['days'] ) . "\t";
}
else {
     $days_TSV = "";
}

By design9 - August 20, 2014

Sorry, I just realized I was looking at the coding for my preview and it worked perfectly for that. 

It doesn't work in the email template. Is there an easy way to make the days of week show up in the email template?