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

Jump to: navigation, search
(Multiple file uploads: new section)
(Multiple file uploads)
Line 33: Line 33:
  
  
If I have multiple files to be uploaded using the form and all files are to go in different location. The below code does not satisfy the needs to do anything of this sort.
+
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
 
after form submission and validation use
  
Line 42: Line 42:
 
       ...
 
       ...
 
}
 
}
 
+
--------------------------------------------
How I can go about that?
+
How this can be done?
 
Thanks.
 
Thanks.

Revision as of 08:48, 12 July 2011

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)

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.