We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Set Radio Button value | Forum

Guna
Guna Mar 11 '15
I am trying to set value for a radio button. But it didn't work. What is wrong?


$whoCanViewArray =array();


$whoCanViewArray = array(          

       GROUPS_BOL_Service::WCV_ANYONE => $language->text('groups', 'form_who_can_view_anybody'),        

       GROUPS_BOL_Service::WCV_INVITE => $language->text('groups', 'form_who_can_view_invite')        );        


$whoCanView = new RadioField('whoCanView');  

$whoCanView->setRequired();

$whoCanView->addOptions($whoCanViewArray);  

$whoCanView->setLabel($language->text('groups', 'form_who_can_view_label')); 

$whoCanView->setValue($whoCanViewArray[0]); 

$this->addElement($whoCanView);

The Forum post is edited by Guna Mar 11 '15
Taissa Team
Taissa Mar 12 '15
Guna, can you clarify what do you want to achieve?
As we can see you are modifying the ow_plugins/groups/controllers/groups.php file.
The default block of this code is:

 $whoCanView = new RadioField('whoCanView');
        $whoCanView->setRequired();
        $whoCanView->addOptions(
            array(
                GROUPS_BOL_Service::WCV_ANYONE => $language->text('groups', 'form_who_can_view_anybody'),
                GROUPS_BOL_Service::WCV_INVITE => $language->text('groups', 'form_who_can_view_invite')
            )
        );
        $whoCanView->setLabel($language->text('groups', 'form_who_can_view_label'));
        $this->addElement($whoCanView);

        $whoCanInvite = new RadioField('whoCanInvite');
        $whoCanInvite->setRequired();
        $whoCanInvite->addOptions(
            array(
                GROUPS_BOL_Service::WCI_PARTICIPANT => $language->text('groups', 'form_who_can_invite_participants'),
                GROUPS_BOL_Service::WCI_CREATOR => $language->text('groups', 'form_who_can_invite_creator')
            )
        );
        $whoCanInvite->setLabel($language->text('groups', 'form_who_can_invite_label'));
        $this->addElement($whoCanInvite);
    }


So, do you want to add a new value for the radio button?
Taissa Team
Taissa Mar 12 '15
Topic was moved from General Questions.
Guna
Guna Mar 12 '15

Thanks for your reply.


I have taken an example from groups. Actually I didn't modify groups plugin.


I really want to know how to check a radio button value by default.