|
[
Permalink
| « Hide
]
Jamie Pratt added a comment - 03/Oct/07 12:49 PM
I don't really understand the problem. Can you explain in more detail and / or include a code sample of code that would produce an error.
In my form, l have
class mod_mymodule_compose_form extends moodleform { $mform->addElement('file', 'attachment', "File Attachment"); The code above works file. But if l change this to group the items so that they will be on the same line as below, l get error when file is submitted: – $marray=array(); lib/formslib.php If you see my comment above, $mform->getElementType($elname) call in the above function is using an array defined in the forms Object called _elementIndex and this array does not have the index the items that have been added using the addGroup method. Hence it is failing. I posted this yesterday on the wrong place: http://tracker.moodle.org/browse/MDL-11537#action_35666
--------------- In doing more research on this, l found that the forms element has an array called [_elementIndex] => Array This array has the location of the items in the array. The getElementType function in QuickForm.php depends on this. But when you had items to a group, the items are not part of this index hence getElementType fails. It would be nice if getElementType can recurse or somehow find item types in a Groups. Or just add the items in the Groups to this index array. I think the problem you are seeing here Mawuli is just related to file upload. To summarise : file upload is failing when the file element is in a group, this is because getElementType is called with the element name and getElementType is not working to get the type of an element within a group. I added Petr as a watcher for this bug as he is the expert on the file upload code.
You are correct about the getElementType function. It needs to be fix to handle file upload within a group.
Let me know when this is fixed and hope it is fixed before 1.9 is released. Thanks for looking at it in the first place. lowering priority -this does not break current code, though I agree this should be fixed in future
|
||||||||||||||||||||||||||||||||||||||||||||||||||