File picker's default value of select .

File picker's default value of select .

by Takeshi Matsuzaki -
Number of replies: 3

I made a repository plugin. It has a select box in a file picker .
I made this conde in print_login() .
-------
$iconsizes[] = (
array('value' => 0,'label' => 'small'),
array('value' => 1,'label' => 'big')
);
$iconsizes[1] = array_merge($iconsizes, array("selected"=> "true"));
//This line seems work well .

$maxicon = new stdClass();
$maxicon->id = 'aid';
$maxicon->type = 'select';
$maxicon->name = 'aname';
$maxicon->options = $iconsizes;

The default vaule was not set . Let me have a hint , please .

Average of ratings: -
In reply to Takeshi Matsuzaki

Re: File picker's default value of select .

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you take a look at the print_login function in 'filepicker.js', then scroll down to the section starting:

                } else if(l[k].type=='select') {

You will find that the options are set up with their value + content, but that there is currently no support for setting the 'selected' element (unless I've missed it, in which case my apologies to Marina who wrote that bit of code).

I think this looks like an improvement that should be posted in tracker.moodle.org (assuming it isn't there already - please search first).

 

 

In reply to Davo Smith

Re: File picker's default value of select .

by Takeshi Matsuzaki -

Hi Davo , thank you for your response .

I checked filepicker.js , as you said it doesn't support the default value in Moodle 2.4.3 and 2.5 beta .

And there seems no posting about it in tracker.moodle.org .

In reply to Davo Smith

Re: File picker's default value of select .

by Takeshi Matsuzaki -

I posted it as 'default value of select in filepicker'. Thank you for your advice .

Let me know one more about filepicker . I want to handle when one picture is selected in a filepicker . I can not find the call back function . I am happy if anyone gives me advice .