<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

/**
 * Add/edit a CAPP (Conseil d'apprentissage) session.
 *
 * @package    local_kid
 */

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/formslib.php');

class local_kid_capp_session_form extends moodleform {

    protected function definition() {
        $mform = $this->_form;
        $isediting = !empty($this->_customdata['isediting']);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $mform->addElement('hidden', 'promotionid');
        $mform->setType('promotionid', PARAM_INT);

        $mform->addElement('text', 'code', get_string('capp_code', 'local_kid'), ['maxlength' => 20]);
        $mform->setType('code', PARAM_TEXT);
        $mform->addRule('code', get_string('required'), 'required', null, 'client');

        $mform->addElement('text', 'libelle', get_string('capp_libelle', 'local_kid'), ['maxlength' => 255, 'size' => 60]);
        $mform->setType('libelle', PARAM_TEXT);
        $mform->addRule('libelle', get_string('required'), 'required', null, 'client');

        if ($isediting) {
            $mform->addElement('advcheckbox', 'active', get_string('competency_active', 'local_kid'));
            $mform->setDefault('active', 1);
        }

        $this->add_action_buttons();
    }
}
