45 lines
1.4 KiB
PHP
45 lines
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 array $params The parameters for form initialization
|
||
|
* @return array Form data based on parameters
|
||
|
*/
|
||
|
abstract public static function init_data(array $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 array $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(array $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();
|
||
|
|
||
|
|
||
|
}
|