1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

radio list loading without selected default value

Discussion in 'Community' started by hanees, May 19, 2019.

  1. hanees

    hanees New Member

    Level: Community
    I have a table with id and points.
    id points
    1 10
    2 20
    3 30

    i am using below code to generate radio list in Eval populate. here issue is radio list loading without selected any value. i need to select id (2) as default value every time form loads. how to do it.

    $db = JFactory::getDbo();
    $db->setQuery('SELECT id, points FROM table ORDER BY id ASC');
    $rows = $db->loadObjectList();
    foreach ($rows as $row) {
    $options[] = JHTML::_('select.option', $row->id, $row->points);
    }
    return $options;
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Well, if you set the element's default to 2, it should default to that on a new form. From then on, it'll select whatever value the element has.

    There's no built in way to set the selection arbitrarily when editing. Defaults only apply on a new form.

    -- hugh
     

Share This Page