I have a series of checkboxes on my form that together form an array when POST'ed. I want to save this data as a string instead (e.g., "##,##,##") before committing to the database.
Here's what I have in the \models\componentname.php:
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
if(isset($data['dancer_id'])) {
$data['dancer_id'] = implode(",", $data['dancer_id']);
}
if (parent::save($data))
{
return true;
}
return false;
}
And here is the custom field type I've created (\models\fields\fieldname.php):
<div class="dancer"><input id="dancer_id" type="checkbox" name="dancer_id[]" value="XXX" />XXX</div>
All other fields in the form save except for this one. Any thoughts? Also I'm not sure how the $data is being passed to the save() function ... maybe I've missed a call somewhere? To get this far, I followed the HelloWorld MVC component tutorial on the Joomla site and the response in this related thread.