Is there a way to set default choice in eval populate radiobutton ?

lcollong

FabriKant d'applications web
Hi,

Using a form as search input, I set a radiobutton element to choose the year based on a sql query :
PHP:
$db = JFactory::getDbo();
$db->setQuery('SELECT DISTINCT YEAR(date_mes) as y FROM MESURE WHERE date_mes > DATE("2000-01-01") ORDER BY y DESC');
$rows = $db->loadObjectList();
foreach ($rows as $row) {
    $options[] = JHTML::_('select.option', $row->y, $row->y);
}
return $options;

It works perfectly. But is there any mean to set the default value (the first choice in my case) ?
 
Nope, unfortunately not. The default (or selected) attribute isn't part of the individual options, it's set elsewhere. Winds up as $d->selected in the ./layouts/fabrik-grid-item.php layout.

We'd have to add that as a separate option in the settings. Not sure how easy / hard it would be.

-- hugh
 
Ok I see. Currently I use the regular dropdown as, in my case, the default value is the first one. It has another advantage compare to radio-button : default value. I'm using this in a module form used as a "complex" search triggering the display of charts (amcharts). When the page is refreshed, the module has to display the previously chosen values. I use session variables to set default values....

Ideally, it should act as a cascading radio button : being able to display a radio button from the result of the query in my first post (like a regular fabrik filter build) restricted by the value of the others selection (regular DBjoin and CDD elements). With some ajax refresh.... and the possibility to set default value.

I think, i'll built this either outside fabrik (in the template) or using a calc element to show up button and set an hidden field....
 
were you able to figure out how to do this?

i am creating a dropdown list using eval populate, then trying to set the selected element either through JHTML OR through the fabrik default. setting the default to the value or text of the option list doesn't work... and their doesn't seem to be a JHML select.options option for which to set as selected.

js to the dom model?
 
Well, as I said, I built the dropdown list such a way that the pre-selected item is in first position of the dropdown. I did not try to manipulate the DOM to change the selected item. So I can't really help you on this one.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top