moodle_local_treestudyplan/classes/local/forms/formbase.php
2023-10-19 17:48:43 +02:00

45 lines
No EOL
1.4 KiB
PHP

<?php
namespace local_treestudyplan\local\forms;
use moodleform;
abstract class formbase extends moodleform {
/**
* Create the form while providing the correct defaults for our type of forms
* @param array $ajaxformdata Provide submitted form data through Ajax here
*
*/
public function __construct($ajaxformdata=null) {
parent::__construct(null, null, 'post', '', null, true, $ajaxformdata);
}
/**
* Generate form data from parameters
* Also validate parameters and access permissions here
*
* @param object $params The parameters for form initialization
* @return array Form data based on parameters
*/
abstract public static function init_data(object $params);
/**
* Validate security access for this form based on the provided parameters
* Return true if validation passes, false or throw an exception if it does not.
*
* @param object $params The parameters for form initialization
* @return bool True if security validation passes.
* @throws \moodle_exception if access denied for a specific reason.
*/
abstract public static function check_security(object $params);
/**
* Process the submission and perform necessary actions
* @return bool True if submission successful
* @throws \moodle_exception if an error must be given for a specific reason.
*/
abstract public function process_submission();
}