add form elements externally in moodle 2.3.3



$choices = array();
$choices['0'] = 'Online course';
$choices['1'] = 'Onsite course';
$mform->addElement('select', 'course', get_string('course'), $choices);
$mform->setDefault('visible', $courseconfig->visible);
if (!has_capability('moodle/course:visibility', $context)) {
$mform->hardFreeze('visible');
if (!empty($course->id)) {
$mform->setConstant('visible', $course->visible);
} else {
$mform->setConstant('visible', $courseconfig->visible);
}
}


$mform->addElement('textarea','address', get_string('address'),'maxlength="500" size="40"');
$mform->addHelpButton('address', 'address');
$mform->setType('address', PARAM_MULTILANG);
/*if (!empty($course->id) and !has_capability('moodle/course:changeaddress', $coursecontext)) {
$mform->hardFreeze('address');
$mform->setConstant('address', $course->address);
}*/

$mform->addElement('text','time', get_string('time'),'maxlength="50" size="20"');
$mform->addHelpButton('time', 'time');
$mform->setType('time', PARAM_MULTILANG);
/*
if (!empty($course->id) and !has_capability('moodle/course:changetime', $coursecontext)) {
$mform->hardFreeze('time');
$mform->setConstant('time', $course->time);
}*/

$deptnames = $DB->get_records('county_info');
$deptlist[0] = "Please Select County";
foreach($deptnames as $deptname)
{
$deptlist[$deptname->id] = $deptname->name;
}
$mform->addElement('select', 'county', 'county', $deptlist);
if( !empty($CFG->county) )
{
$mform->setDefault('county', $CFG->county);
}
else
{
$mform->setDefault('county', '');
}



$mform->addElement('text','startdates', 'Start date', "id='txtFromDate'", 'maxlength="50" size="20"');
$mform->addHelpButton('startdates', 'startdates');
$mform->setType('startdates', PARAM_MULTILANG);

$mform->addElement('text','enddate', 'End date', "id='txtToDate'", 'maxlength="50" size="20"');
$mform->addHelpButton('enddate', 'enddate');
$mform->setType('enddate', PARAM_MULTILANG);


Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools