Form elements in form elements

Form elements in form elements

by Gareth J Barnard -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

With Moodle 3.3 can I add form elements to other form elements?  So with reference to https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#radio - could I create two radio groups and have the second 'within' the first's 'radio'?  So... to have:

(o) Option one:

(o) Option one one.

(o) Option one two.

(o) Option one three [text input].

(o) Option two: [text input] [select input].

Thus only have 'Option one ...' active when 'Option one' is clicked on.  And have radio elements with appended select / text inputs?

I'm an experienced Moodler but stumped on this one!

Thanks,

Gareth



Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: Form elements in form elements

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

After many hours I found out that its impossible to have a Form group within a form group in the Moodle forms API and standard HTML markup does not allow elements within radio inputs.  I've gone for a checkbox / radio solution with disabledIf logic.  It did find out though that disabledIf does not work well with two radio groups within an addGroup.  All being well when the job is done the code will be within a plugin on Moodle.org for all to see.

Cheers,

Gareth