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.
Understood- the values I'm sending over are indeed checked. The above was just a sample.
Checkboxes do not get posted when they are unchecked.
They get posted only when they are checked.
--
You received this message because you are subscribed to a topic in the Google Groups "Joomla! General Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-general/EhH0qoRk1uw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.
Cross post from StackExchange... 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.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
<input id="dancer_id" type="checkbox" name="jform[dancer_id][]" value="2261" checked>Array ( [entry_id] => 11635 [studio_id] => 126 [location_id] => 30 [perf_title] => Amazing Twinkle [choreographer] => Bob [dancer_id] => Array ( [0] => 2261 [1] => 2270 ) [avg_age] => 11 [entrydiv_id] => 1 [perflvl_id] => 10 [dancecat_id] => 19 [agediv_id] => 24 [dvd_auth] => 1 [breaktime] => 0 [notes] => [catid] => 0 [dateadded] => 2015-12-19 [datemodified] => 2016-01-31 [published] => 1 [mss] => 0 [params] => Array ( [show_category] => ) [asset_id] => [rules] => Array ( [core.delete] => Array ( [6] => 1 ) [core.edit] => Array ( [6] => 1 [4] => 1 ) ) [tags] => ) if(isset($data['dancer_id'])) {
$data['dancer_id'] = implode(",", $data['dancer_id']);
}Array ( [entry_id] => 11635 [studio_id] => 126 [location_id] => 30 [perf_title] => Amazing Mayzie [choreographer] => Erin Koehler [dancer_id] => 2261,2270 [avg_age] => 11 [entrydiv_id] => 1 [perflvl_id] => 10 [dancecat_id] => 19 [agediv_id] => 24 [dvd_auth] => 1 [breaktime] => 0 [notes] => [catid] => 0 [dateadded] => 2015-12-19 [datemodified] => 2016-01-31 [published] => 1 [mss] => 0 [params] => Array ( [show_category] => ) [asset_id] => [rules] => Array ( [core.delete] => Array ( [6] => 1 ) [core.edit] => Array ( [6] => 1 [4] => 1 ) ) [tags] => )return parent::save($data);Maybe you don.t get it because its not in the jform array.
use: name=jform[dancer_id][]
Op 28-01-16 om 01:04 schreef Ryan Matthews:
--Cross post from StackExchange... 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.
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
-- You received this message because you are subscribed to the Google Groups "Joomla! General Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com. To post to this group, send email to joomla-de...@googlegroups.com. Visit this group at https://groups.google.com/group/joomla-dev-general. For more options, visit https://groups.google.com/d/optout.