Skip to content

forms duplicatable fieldsets

David Spreekmeester edited this page Dec 2, 2014 · 1 revision

Creating duplicatable fieldsets

Whenever you want to use Javascript to duplicate a given (set of) input(s), use Garp_Form_Subform_Array. This class ensures your submitted data will be neatly organised in arrays.

Use Garp_Form_Subform_Array as follows:

<?php
// In a Garp_Form context
$subform = new Garp_Form_Subform_Array(array(
	'name' => 'teacher',
	'duplicatable' => true,
	'class' => 'grid-lorem-ipsum' // 'garp-subform' is default
));

$subform->addElement('text', 'first_name', array(
	'label' => 'First name:',
	// 'index' => 0 is default
));

$subform->addElement('text', 'last_name', array(
	'label' => 'Last name:'
));

$this->addSubForm($subform);
?>
Clone this wiki locally