Source for file catform.class.php
Documentation is available at catform.class.php
include_once (dirname(__FILE__ ). '/../../../inc/global.inc.php');
include_once (dirname(__FILE__ ). '/../be.inc.php');
require_once (api_get_path(LIBRARY_PATH). 'formvalidator/FormValidator.class.php');
* Extends formvalidator with add&edit forms
* @package dokeos.gradebook
* Builds a form containing form items based on a given parameter
* @param int form_type 1=add, 2=edit,3=move,4=browse
* @param obj cat_obj the category object
* @param string form name
function CatForm($form_type, $category_object,$form_name,$method = 'post',$action= null)
parent :: __construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset ($category_object))
if ($this->form_type == self :: TYPE_EDIT)
elseif ($this->form_type == self :: TYPE_ADD)
elseif ($this->form_type == self :: TYPE_MOVE)
elseif ($this->form_type == self :: TYPE_SELECT_COURSE)
* This function will build a move form that will allow the user to move a category to
$renderer->setElementTemplate('<span>{element}</span> ');
$select = $this->addElement('select','move_cat',null,null);
for ($i= 0;$i< $cat[2];$i++ )
$select->addoption($line. ' '. $cat[1],$cat[0]);
$select->addoption($line. ' '. $cat[1],$cat[0],'disabled');
* This function builds an 'add category form, if parent id is 0, it will only
//check if we are a root category
//if so, you can only choose between courses
$select = $this->addElement('select','select_course',array(get_lang('PickACourse'),'test'), null);
if (count($coursecat)== 0)
$select->addoption(get_lang('CourseIndependent'),'COURSEINDEPENDENT','disabled');
$select->addoption(get_lang('CourseIndependent'),'COURSEINDEPENDENT');
//only return courses that are not yet created by the teacher
foreach($coursecat as $row)
$select->addoption($row[1],$row[0]);
* Builds an form to edit a category
$this->add_textfield('certif_min_score', get_lang('CertificateMinScore'),false,array('size'=> '4','maxlength'=> '4'));
$this->addElement('textarea', 'description', get_lang('Description'),array('rows'=> '3','cols' => '34'));
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$this->addRule(array ('certif_min_score', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
* This function builds an 'select course' form in the add category process,
* if parent id is 0, it will only show courses
$select = $this->addElement('select','select_course',array(get_lang('PickACourse'),'test'), null);
//only return courses that are not yet created by the teacher
foreach($coursecat as $row)
$select->addoption($row[1],$row[0]);
parent :: setDefaults($defaults);
|