Dynamically hide/show radiobutton choices upon a sql query on load

lcollong

FabriKant d'applications web
Happy new year to everybody and a special thought to Rob and Hugh to make 2014 a great Fabrik's one ! :)

I'd like to hide or show some radiobuttons choices based on a sql query at the time the form is loaded (see screenshot). Is this possible ? I've tried some JS syntax to disable one of the choices but the best I can achieve is to disable user choice. I can't hide it. Is the JS solution the right one ? Is this possible in php using form plugin onLoad ?
 

Attachments

  • Capture2.JPG
    Capture2.JPG
    25.8 KB · Views: 517
Hi, I've just added something which was already present for the dropdown element to the radio button's options.
There's now an advanced tab section with a 'Eval populate' code area, where you could run your query then build an array of options to return e.g.

PHP:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, label')->from('foo')->where('bar = 1');
$db->setQuery($query);
$opts = $db->loadObjectList();
 
$return = array();
foreach ($opts as $opt)
{
  $return[] = JHTML::_('select.option', $opt->id, $opt->value);
}
 
return $return;

changes are in this commit:
https://github.com/Fabrik/fabrik/commit/d3cad4ceda2640d40d31633c48f8bd7f25572534
 
Hi, I've just added something which was already present for the dropdown element to the radio button's options.
There's now an advanced tab section with a 'Eval populate' code area, where you could run your query then build an array of options to return e.g.

PHP:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, label')->from('foo')->where('bar = 1');
$db->setQuery($query);
$opts = $db->loadObjectList();
 
$return = array();
foreach ($opts as $opt)
{
  $return[] = JHTML::_('select.option', $opt->id, $opt->value);
}
 
return $return;

changes are in this commit:
https://github.com/Fabrik/fabrik/commit/d3cad4ceda2640d40d31633c48f8bd7f25572534
 
Hi Rob,

Thanks for that. It seems perfect but I have the feeling you made the update on the J3/F3.2 branch. My question was related to a site under J2.5/Master branch.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top