Hello,
I have been working off a wonderful tutorial to create forms from Bob's Guides found here:
http://bobsguides.com/custom-db-tables.html. I've used it as a basis to build a simple form but have hit a roadblock. I am trying to add
First the html:
<form method="post" action="[[~[[*id]]]]">
<fieldset class="loginLoginFieldset">
<input type="hidden" name="quoteId" value="[[+id]]"/>
<label for="eFirstName">First Name</label>
<input type="text" name="eFirstName" id="eFirstName" value="[[+eFirstName]]"/>
<label for="eMI">Middle Initial</label>
<input type="text" name="eMI" id="eMI" value="[[+eMI]]"/>
<label for="eLastName">Last Name</label>
<input type="text" name="eLastName" id="eLastName" value="[[+eLastName]]"/>
<label for="eCity">City</label>
<input type="text" name="eCity" id="eCity" value="[[+eCity]]"/>
<label for="bowlgames">Please check which items you are interested in?</label>
<input type="checkbox" name="item_chk[]" value="value1" />Value 1<br />
<input type="checkbox" name="item_chk[]" value="value2" />Value 2<br />
<input type="checkbox" name="item_chk[]" value="value3" />Value 3<br />
<input type="submit" name="submit" id="submit" value="submit"/>
</fieldset>
</form>
Now my PHP:
<?php
/* CreateQuote Snippet */
if (isset($_POST['submit']) &&
($_POST['submit'] == 'submit')) {
/* Form has been submitted */
/* You might want to check for empty
* required fields here */
/* We need to load our class so newObject() will work */
$path = MODX_CORE_PATH . 'components/online_app/';
$result = $modx->addPackage('online_app',$path .
'model/','xxx_');
if (! $result) {
return 'Failed to add package';
}
$fields = array(
'eFirstName' => $_POST['eFirstName'],
'eMI' => $_POST['eMI'],
'eLastName' => $_POST['eLastName'],
'eCity' => $_POST['eCity'],
);
$online_app = $modx->newObject('application', $fields);
if ( $onlineapp->save()) {
$output = "Fields Inputted";
} else {
$output = "Error";
}
} else {
/* Not a repost, just display the form */
$output = $modx->getChunk('online_appTpl');
}
return $output;
What do I place in the PHP that will collect the selections for the "item_chk". I have come across many variations online but the best that ever happens, when I check any of the items on my form is the word "array" is posted in that field in the database. I'm at a complete loss for something fairly simple.
Thank you in advance for any help.