php - Add dynamic string in moodle form help icon -
i new in moodle. have requirement add dynamic text in icon created using $mform->addhelpbutton(); function. not able this.
can tell me way pass dynamic string in moodles form icon.
the addhelpbutton() method has parameter $component contains current text shown when clicking onto icon (). text read $string array defined in language file.
the trick here array element can built dynamically:-)
let's make example: in mod_form.php build icon with:
$mform->addhelpbutton ( 'element_name', 'your_identifier', 'your_help_text' );
the text your_help_text read in language file with:
$string ['your_help_text_help'] = 'this static text';
here change line with:
$string ['your_help_text_help'] = get_dynamic_help_string($any_parameter);
and define function:
function get_dynamic_help_string($any_parameter) { $text = dynamic text current date: ; $text .= ' '.date("y/m/d"); return $text; }
now, time refresh form, text built dynamically. of course, can use logic here, if want.
note: need here manage cache of plugin in order newest result of function. please, refer link deleting moodle cache.
Comments
Post a Comment