Difference between revisions of "Talk:lib/formslib.php Form Definition"

Jump to: navigation, search
(Very disappointing, that nested fieldsets are not supported :()
 
(7 intermediate revisions by 5 users not shown)
Line 2: Line 2:
  
 
: Hi Howard, You can just add <nowiki>{{Moodle 2.0}}</nowiki> to those items. I did that for 'duration'. --[[User:Frank Ralf|Frank Ralf]] 11:54, 23 July 2009 (UTC)
 
: Hi Howard, You can just add <nowiki>{{Moodle 2.0}}</nowiki> to those items. I did that for 'duration'. --[[User:Frank Ralf|Frank Ralf]] 11:54, 23 July 2009 (UTC)
 +
 +
==No default value attribute for editor??==
 +
tried the context key but doesn't work.
  
 
== Use Static elements with care? ==
 
== Use Static elements with care? ==
Line 28: Line 31:
 
'''See example QuickForm solution of nested fieldset here:'''<br>
 
'''See example QuickForm solution of nested fieldset here:'''<br>
 
[http://pear.saltybeagle.com/HTML_QuickForm_Renderer_Tableless/stack.php http://pear.saltybeagle.com/HTML_QuickForm_Renderer_Tableless/stack.php]<br>
 
[http://pear.saltybeagle.com/HTML_QuickForm_Renderer_Tableless/stack.php http://pear.saltybeagle.com/HTML_QuickForm_Renderer_Tableless/stack.php]<br>
--[[User:- -|- -]] 18:02, 23 March 2011 (UTC)
+
Konrad Lorinczi [[User:- -|- -]] 18:02, 23 March 2011 (UTC)
 +
 
 +
== Multiple file uploads? ==
 +
 
 +
 
 +
If one has multiple files to be uploaded using the form and all files are to go in different location. It feels like, the below code does not satisfy the needs to do anything of this sort.
 +
------------------------------------------
 +
after form submission and validation use
 +
 
 +
if ($data = $mform->get_data()) {
 +
      ...
 +
    $mform->save_files($destination_directory);
 +
      ...
 +
}
 +
--------------------------------------------
 +
How this can be done?
 +
Thanks.
 +
 
 +
==Dependent Dropdown Lists==
 +
 
 +
Does Formslib support adding dependent dropdown lists to a form? This is where the options that are displayed on list2 are dependent on the option that is selected on list1.
 +
The [https://moodle.org/mod/forum/discuss.php?d=163019 how to implement dependent dropdown lists] discussion on the Using Moodle forum talks about something similar and offers a "hacky" approach. But that was in 2010. Can this be easily done in Moodle 2.5/2.6?
 +
 
 +
== setType default, source links ==
 +
 
 +
In the section documenting setType(), it would be great to have links to the source of not only where these are defined (linking the reference to moodlelib.php), but also where they get applied, that is, where the cleaning happens.  When I look at this section, I would expect to find information on what the default type is, if none is set, and details on what cleaning happens, or where to find this in the source.  How are invalid values dealt with?  There is also a reference to format_text(), which could use a link to source.
 +
 
 +
How can we put links to source into the documentation?
 +
 
 +
Also helpful would be a discussion of how to set the type of elements created with repeat_elements().  Some clues to this can be found in lib/formslib.php:1027:repeat_elements().
 +
 
 +
: Cleaning input is done in clean_param, also in moodlelib.php. To add a link here, just put the URL, like http://moodle.org/. If you want to do something more clever, like change the link text, then see the [[Help:Editing|Editing help]].--[[User:Tim Hunt|Tim Hunt]] ([[User talk:Tim Hunt|talk]]) 01:30, 15 May 2014 (WST)

Latest revision as of 17:30, 14 May 2014

There's items on here (e.g. 'duration') that are 2.0 only. Please can people adding them mark them as such to avoid confusion. Ta --Howard Miller 11:42, 23 July 2009 (UTC)

Hi Howard, You can just add {{Moodle 2.0}} to those items. I did that for 'duration'. --Frank Ralf 11:54, 23 July 2009 (UTC)

No default value attribute for editor??

tried the context key but doesn't work.

Use Static elements with care?

Why are static elements listed as being used with care?

Please do not create conditional elements in definition(), the definition() should not directly depend on the submitted data.

I'm really not sure what this means. Does it actually mean "do not create elements that are conditional upon the values of other submitted elements" as opposed to not creating conditional elements at all? Lots of forms have conditional elements --Howard Miller 13:06, 6 February 2011 (UTC)

Yes, it means don't create things that are conditional on the data that the form will be editing. It is OK to condition on admin settings (e.g. if conditional activities are turned off, those options do not appear on the mod_edit forms. Or, perhaps, on capabilities. However, in that case you have to be careful. If someone without the capability uses the form, you have to make sure that when they submit, you don't overwrite the correct value in the database with blank from the form. In that situation, it may be better to use hardFreeze on those form elements, instead of conditionally omitting them.--Tim Hunt 15:14, 6 February 2011 (UTC)

Very disappointing, that nested fieldsets are not supported :(

"$mform->addElement('header', 'nameforyourheaderelement', get_string('titleforlegened', 'modulename')); You can't yet nest these visible fieldsets unfortunately. But in fact groups of elements are wrapped in invisible fieldsets. You close a fieldset with moodle_form's closeHeaderBefore method. You tell closeHeaderBefore the element before you wish to end the fieldset. A fieldset is automatically closed if you open a new one."


Should be possible to nest fieldsets! Please add this feature!


As I know this feature was already added to QuickForms.
See example QuickForm solution of nested fieldset here:
http://pear.saltybeagle.com/HTML_QuickForm_Renderer_Tableless/stack.php
Konrad Lorinczi - - 18:02, 23 March 2011 (UTC)

Multiple file uploads?

If one has multiple files to be uploaded using the form and all files are to go in different location. It feels like, the below code does not satisfy the needs to do anything of this sort.


after form submission and validation use

if ($data = $mform->get_data()) {

     ...
   $mform->save_files($destination_directory);
     ...

}


How this can be done? Thanks.

Dependent Dropdown Lists

Does Formslib support adding dependent dropdown lists to a form? This is where the options that are displayed on list2 are dependent on the option that is selected on list1. The how to implement dependent dropdown lists discussion on the Using Moodle forum talks about something similar and offers a "hacky" approach. But that was in 2010. Can this be easily done in Moodle 2.5/2.6?

setType default, source links

In the section documenting setType(), it would be great to have links to the source of not only where these are defined (linking the reference to moodlelib.php), but also where they get applied, that is, where the cleaning happens. When I look at this section, I would expect to find information on what the default type is, if none is set, and details on what cleaning happens, or where to find this in the source. How are invalid values dealt with? There is also a reference to format_text(), which could use a link to source.

How can we put links to source into the documentation?

Also helpful would be a discussion of how to set the type of elements created with repeat_elements(). Some clues to this can be found in lib/formslib.php:1027:repeat_elements().

Cleaning input is done in clean_param, also in moodlelib.php. To add a link here, just put the URL, like http://moodle.org/. If you want to do something more clever, like change the link text, then see the Editing help.--Tim Hunt (talk) 01:30, 15 May 2014 (WST)