Forums | Mahara Community
Developers
/
Create an array of configdatas in a blocktype plugin for Mahara
13 July 2020, 20:01
Hello,
I'm trying to create fields when in a blocktype there are for example 2 fields in a configdata:
But in this way I can't access to the array fields ('infos' fields). The result is empty :
How can I do it with the forms library Pieforms?
Thank you very much!
21 July 2020, 11:30
Hi De Chiara Antonella,
If I understand correctly you are wanting to pair together two related fields?
I think what you might need is a fieldset element, eg
for ($i = 1; $i <= $configdata['nbofevents']; $i++) {
$data['event' . $i . 'set'] = array(
'type' => 'fieldset',
'legend' => get_string( ... fieldset title ... ),
'elements' => array(
'event' . $i => array(
'type' => 'text',
'title' => get_string( ... event title ... ),
.... and so on
),
'eventtext' . $i => array (
'type' => 'text',
'title' => get_string( ... eventtext title ... ),
.... and so on
),
),
);
}
That way you can group fields into sub groups of all the elements - an example of this is the Admin -> Configuration -> Site options form where the form is split into groups with fieldsets
Cheers
Robert
21 July 2020, 19:34
Hi Robert,
Thanks a lot it's perfect, it's just what I wanted!
Have a nice day and thanks again :-)