MDL-73635 tool_componentlibrary: Move example codes to examples folders

This commit is contained in:
Jun Pataleta 2022-01-21 01:02:27 +08:00
parent e63604fb6d
commit 080e12e9ac
4 changed files with 14 additions and 13 deletions

View File

@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_componentlibrary;
namespace tool_componentlibrary\local\examples\formelements;
/**
* Example form to showcase the rendering of form fields.
@ -30,7 +30,7 @@ namespace tool_componentlibrary;
* @copyright 2021 Bas Brands <bas@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class exampleform extends \moodleform {
class example extends \moodleform {
/**
* Elements of the test form.
*/

View File

@ -23,7 +23,7 @@ Form elements are styled using the .form-control class, see the [Bootstrap](/boo
## Example form elements
The example form below is showing an ifram with an actual Moodle form. Use the toggle options to display the different states for the form.
The example form below is showing an iframe with an actual Moodle form. Use the toggle options to display the different states for the form.
<iframe src="../../../../formfields.php" style="overflow:hidden;height:4000px;width:100%;border:0" title="Moodle formfields"></iframe>
<iframe src="../../../../examples/formfields.php" style="overflow:hidden;height:4000px;width:100%;border:0" title="Moodle form fields"></iframe>

View File

@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../../config.php');
require_once(__DIR__ . '/../../../../config.php');
require_once($CFG->dirroot.'/lib/formslib.php');
require_login();
@ -34,14 +34,15 @@ $repeatcount = optional_param('test_repeat', 1, PARAM_INT);
$PAGE->set_pagelayout('embedded');
$url = new moodle_url('/admin/tool/componentlibrary/formfields.php');
$url = new moodle_url('/admin/tool/componentlibrary/examples/formfields.php');
$toggles = (object)[];
$toggles->defaulturl = $url;
$toggles->helpurl = new moodle_url('/admin/tool/componentlibrary/formfields.php', ['help' => 1]);
$toggles->requiredurl = new moodle_url('/admin/tool/componentlibrary/formfields.php', ['required' => 1]);
$toggles->bothurl = new moodle_url('/admin/tool/componentlibrary/formfields.php', ['help' => 1, 'required' => 1]);
$toggles->mixedurl = new moodle_url('/admin/tool/componentlibrary/formfields.php', ['help' => 1, 'required' => 1, 'mixed' => 1]);
$toggles->helpurl = new moodle_url('/admin/tool/componentlibrary/examples/formfields.php', ['help' => 1]);
$toggles->requiredurl = new moodle_url('/admin/tool/componentlibrary/examples/formfields.php', ['required' => 1]);
$toggles->bothurl = new moodle_url('/admin/tool/componentlibrary/examples/formfields.php', ['help' => 1, 'required' => 1]);
$toggles->mixedurl = new moodle_url('/admin/tool/componentlibrary/examples/formfields.php',
['help' => 1, 'required' => 1, 'mixed' => 1]);
$PAGE->set_url($url);
$PAGE->set_context(context_system::instance());
@ -49,10 +50,10 @@ $PAGE->set_context(context_system::instance());
$PAGE->set_heading('Moodle form fields');
$PAGE->set_title('Moodle form fields');
$form = new \tool_componentlibrary\exampleform($url, ['repeatcount' => $repeatcount]);
$form = new \tool_componentlibrary\local\examples\formelements\example($url, ['repeatcount' => $repeatcount]);
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('tool_componentlibrary/moodleformtoggles', $toggles);
echo $OUTPUT->render_from_template('tool_componentlibrary/examples/formelements/toggles', $toggles);
$form->display();
echo $OUTPUT->footer();

View File

@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template tool_componentlibrary/clipboardbutton
@template tool_componentlibrary/examples/formelements/toggles
Example context (json):
{