How to set/change the label of a radio button at run time

How to set/change the label of a radio button at run time

by Simon Ranjith J -
Number of replies: 0

Hello there,

Lately I enrolled myself in one of Moodle developer courses - Introduction to moodle programming - and have been building a simple block.

The challenge I'm facing here is this. I have a simple form with radio buttons and want to change/set the label of a radio button at run time. Is that feasible? If so, could someone tell me how?

I have been able to change the 'label' for form elements such as textboxes and static labels.

question_form.php :

$mform->addElement('static', 'question','');

question.php :

$record = $DB->get_records_select('block_sob',"id = '$q_no'");
$toform['question'] = $record[$q_no]->question; 
$toform -> an instance of form class
question -> name of the static form element

Thanks,

Simon

Average of ratings: -