• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Populate the Checkbox Group field,

Populate the Checkbox Group field, 10 months 3 weeks ago #42827

  • sintcorp
  • sintcorp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
I need to populate the Checkbox Group field, reading from the database, bringing the values with checked, according to the records inside the database.

I managed to do the items and with the checked, but the listing is grouping and I am not able to update/submit the record of that field.

Does anyone know of any documentation on how to poll this field?

my script

//<code>
$items = array();
$db = JFactory::getDbo();
$user = JFactory::getUser();

$query = $db->getQuery(true);
$query->select('a.id, a.title, IF(b.group_id IS NOT NULL, 1, 0) AS checked')
->from($db->quoteName('#__usergroups', 'a'))
->leftJoin($db->quoteName('#__user_usergroup_map', 'b') . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.group_id') . ' AND ' . $db->quoteName('b.user_id') . ' = ' . $db->quote($user->id) . ')')
->where('a.parent_id IN (16, 17, 24, 27)');

$db->setQuery($query);
$results = $db->loadObjectList();

foreach ($results as $result)
{
$value = $result->id;
$label = $result->title;
$checked = $result->checked ? 'checked' : '';
$items[] = "<input type='checkbox' name='form[assunto-de-interesse][]' class='rsform-checkbox form-check-input' id='assunto-de-interesse{$value}' value='{$value}' {$checked}> <label id='assunto-de-interesse{$value}' for='assunto-de-interesse{$value}' class='form-check-label'>{$label}</label>";
}

$items = implode("<br>", $items);

return $items;
//</code>
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!