set of fields to replicate

set of fields to replicate

de către Daniele Cordella-
Număr de răspunsuri: 2
Imaginea Core developers Imaginea Plugin developers
I need to create a moodle module offering 20 different moodle forms of 10/12 fields each one.
The first 5 fields are always the same for each form.
Can I find a smart way to build all my forms using formslib and without duplicating the first set of five fields each time?

Thank you in advance.
Media notelor: -
Ca răspuns la Daniele Cordella

Re: set of fields to replicate

de către Eloy Lafuente (stronk7)-
Imaginea Core developers Imaginea Documentation writers Imaginea Moodle HQ Imaginea Particularly helpful Moodlers Imaginea Peer reviewers Imaginea Plugin developers Imaginea Testers
Hi Daniele,

AFAIK... it's possible to extend formslib, creating new forms by extending the MoodleQuickForm_group class.

So you could create one DanieleQuickForm_common class with all your common fields and methods.

And then, I guess you can create your 20 different forms by extending the DanieleQuickForm_common, handling in each one exclusively the particular fields.

Note I'm talking in theory, hehe... never have done that, really. face cu ochiul I guess you have to be careful about "child" forms calling "parent" methods and so on but should work.

You can find some examples of that sort of extension and inheritance at: lib/form.

Hope this helps... ciao surâs
Ca răspuns la Eloy Lafuente (stronk7)

Re: set of fields to replicate

de către Daniele Cordella-
Imaginea Core developers Imaginea Plugin developers
Tomorrow morning during the creation of a document I promised to a Moodle friend, I'll try.
face cu ochiul
Thank you.