General developer forum

change action url in admin settings pages

 
Picture of Hossein Poursaeedi
change action url in admin settings pages
 

guys ,


is there any way , we change form action address in admin setting pages?
i want to add some more query string instead of "section" only


thanks

 
Average of ratings: -
Picture of Darko Miletić
Re: change action url in admin settings pages
Core developersParticularly helpful Moodlers

The only way to do that would be to change the core code and I would strongly advise against that.

What are you trying to accomplish (why do you need the extra parameter)?


 
Average of ratings: -
Picture of Hossein Poursaeedi
Re: change action url in admin settings pages
 

i dont wanna touch the core ,, i have some extra config setting, i made a link to new setting page and it will redirect back to the setting pages with GET method, in setting page i will check query string and add extra config field , but, the "save changes" button wont save it .

when i debug the code, iv get it that it will sent it to same page (without my query string) then save it. 


by the way, im sure there should be some update action url, like we change in mform, but in admin setting .

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: change action url in admin settings pages
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

If you just want to validate admin settings before savnig them, then I think you can go it by creating your own subclass of admin_setting, or admin_setting_configtext, and overriding the validate() method.

 
Average of ratings: -
Picture of Hossein Poursaeedi
Re: change action url in admin settings pages
 

Thanks for your reply Tim,
let me explain you what i did,  currently i have a plugin , with some sub component which need their own settings.
In main setting page, i have listed all components with "setting" link. when user click on the setting , it will redirect back to main settings page by 'section' plus my query string (GET method) and in main setting i will check, if there is param, i will add 3 more option like configtext and configcolorbox, but as i understand, when i click on "save Changes", it will post to the same main setting page (without my query string) and those 3 extra fields will gone. so i just thinking of changing form action to "admin/settings,php?section=xxx&myvar=yyy"  or, as i understand, moodle have 3 hidden types field which one of those are 'return', so if i can assign data to it also can be fine to me.


by the way, is there any way which we have our own hidden type in admin setting?
or is it anyway we assign manually data to post? like we do in php  $_POST, when i check main moodle code, its play with cookies and i dont know if any options there,

i know i can play with sessions, but i dont wanna touch it. thanks

 
Average of ratings: -
Picture of Jay Darnell
Re: change action url in admin settings pages
 

How does one go about creating their own subclass of admin_setting_configtext? I know how to write the code to do this but am unsure where to put it. This is my first time using Moodle. What I'm trying to do is store a few URLS in my theme settings for things like social media links for the organization which I could then use in page templates. I figured I could create a new class called admin_setting_configurl which will inherit from admin_setting_configtext and ultimately check to be sure the string entered is a valid URL but I'm not sure where to put this.

If this already exists in Moodle please let me know as I've been unable to find anything that would work while reading through adminlib.php 

 
Average of ratings: -
Picture of Richard Oelmann
Re: change action url in admin settings pages
Core developersParticularly helpful MoodlersPlugin developersTesters

Use the configtext with PARAM_URL?

eg:

// Website url setting.
$name = 'theme_uogateen/website';
$title = get_string('website', 'theme_uogateen');
$description = get_string('websitedesc', 'theme_uogateen');
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_URL);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

Richard

 
Average of ratings: -
Picture of Jay Darnell
Re: change action url in admin settings pages
 

Very interesting. Thank you for that Richard. After posting my initial question last night I learned we can pass regular expressions into the $paramtype variable in the constructor for admin_setting_configtext. Is there a place in the online documentation where I can find a list of valid constants for this variable?

PARAM_RAW
PARAM_INT
PARAM_URL

I'm curious what else can be passed here.

 
Average of ratings: -
Picture of Jay Darnell
Re: change action url in admin settings pages
 

For anyone else curious about this sort of thing, check the file /lib/moodlelib.php for a list of constants.

 
Average of ratings: -