Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 53... Línea 53...
53
     *
53
     *
54
     * @param string $action The action attribute for the form.
54
     * @param string $action The action attribute for the form.
55
     * @param array $customdata Data to set during instance creation.
55
     * @param array $customdata Data to set during instance creation.
56
     * @param string $method Form method.
56
     * @param string $method Form method.
57
     */
57
     */
58
    public function __construct(string $action = null, array $customdata = null, string $method = 'post') {
58
    public function __construct(?string $action = null, ?array $customdata = null, string $method = 'post') {
59
        parent::__construct($action, $customdata, $method);
-
 
60
        $this->contextid = $customdata['contextid'];
59
        $this->contextid = $customdata['contextid'];
61
        $this->plugin = $customdata['plugin'];
60
        $this->plugin = $customdata['plugin'];
62
        $this->id = $customdata['id'];
61
        $this->id = $customdata['id'] ?? 0;
-
 
62
        parent::__construct($action, $customdata, $method);
Línea 63... Línea 63...
63
 
63
 
64
        $mform =& $this->_form;
64
        $mform =& $this->_form;
65
        $mform->addElement('hidden', 'contextid', $this->contextid);
65
        $mform->addElement('hidden', 'contextid', $this->contextid);
Línea 71... Línea 71...
71
        $mform->addElement('hidden', 'id', $this->id);
71
        $mform->addElement('hidden', 'id', $this->id);
72
        $this->_form->setType('id', PARAM_INT);
72
        $this->_form->setType('id', PARAM_INT);
73
    }
73
    }
Línea 74... Línea 74...
74
 
74
 
-
 
75
    /**
-
 
76
     * Add elements to form
-
 
77
     */
-
 
78
    protected function definition() {
-
 
79
        global $DB;
-
 
80
        // Add custom fields to the form.
-
 
81
        $content = $DB->get_record('contentbank_content', ['id' => $this->id]);
-
 
82
        $handler = \core_contentbank\customfield\content_handler::create();
-
 
83
        $handler->instance_form_definition($this->_form, $this->id);
-
 
84
        if ($content) {
-
 
85
            $handler->instance_form_before_set_data($content);
-
 
86
        }
-
 
87
        $this->set_data($content);
-
 
88
    }
-
 
89
 
75
    /**
90
    /**
76
     * Overrides formslib's add_action_buttons() method.
91
     * Overrides formslib's add_action_buttons() method.
77
     *
92
     *
78
     *
93
     *
79
     * @param bool $cancel
94
     * @param bool $cancel