Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

lib/formslib.php setAdvanced: Difference between revisions

From MoodleDocs
No edit summary
Line 19: Line 19:
==moodleform_mod::show_advanced_button()==
==moodleform_mod::show_advanced_button()==


Shows a button to show or hide the advanced elements in a form. The elements will be unhidden with javascript if it is on or if not then the form will be sumbitted and redisplayed with the elements shown or hidden. Within moodleform's definition method you call this method like this :
Shows a button to show or hide the advanced elements in a form. The elements will be unhidden with javascript if it is available or if not then the form will be submitted and redisplayed with the elements shown or hidden as appropriate. The action of the button and label of the button toggle to show advanced elements or hide them.
 
Within moodleform's definition method you call this method like this :


<code>
<code>

Revision as of 11:10, 14 December 2006

You can use MoodleQuickForm's method setAdvanced to specify a form element is an advanced option :

       $mform->addElement('select', 'display', get_string('displaymode', 'choice'), $CHOICE_DISPLAY);
       $mform->setAdvanced('display');

setAdvanced takes a second boolean parameter which defaults to true. True means set this control as an advanced control. False means it is not advanced.

       $mform->addElement('header', 'miscellaneoussettingshdr', get_string('miscellaneoussettings', 'form'));
       $mform->setAdvanced('miscellaneoussettingshdr');

Will set the header element miscellaneoussettingshdr and all the elements it contains to advanced.

And if you set all elements within a header to advanced then the header is automatically set to advanced.

moodleform_mod::show_advanced_button()

Shows a button to show or hide the advanced elements in a form. The elements will be unhidden with javascript if it is available or if not then the form will be submitted and redisplayed with the elements shown or hidden as appropriate. The action of the button and label of the button toggle to show advanced elements or hide them.

Within moodleform's definition method you call this method like this :

     $this->show_advanced_button();

Typically you will include the button at the top and the bottom of the page by calling the method twice.