Reorder reindex elements in a form

Reorder reindex elements in a form

Pedro Garcia - මගින්
Number of replies: 1

Hi team,

I would like use  $mform->addElement();


and give an index to this specific element for displaying it as the second element in the form rather the fifth. The form comes from core and I would like reorder it in my theme.

Is that possible? 

Regards

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Pedro Garcia

Re: Reorder reindex elements in a form

Tim Hunt - මගින්
Core developers ගේ පින්තුරය Documentation writers ගේ පින්තුරය Particularly helpful Moodlers ගේ පින්තුරය Peer reviewers ගේ පින්තුරය Plugin developers ගේ පින්තුරය
For that, don't use addElement. Use insertElementBefore.

Here is an example picked at random from the code https://github.com/moodle/moodle/blob/511a87f5fc357f18a4c53911f6e6c7f7b526246e/badges/classes/form/badge.php#L80
ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -