Working with forms with deep nested arrays

If you have set up your form elements such that they are using deep nested array structure in their names as shown below.

1
<input type="text" name="customer_info[delivery_details][postcode]" />
<input type="text" name="customer_info[delivery_details][postcode]" />

You will need to call the following code during form element configuration:

1
$element->setIsArray(true);
$element->setIsArray(true);

This will tell the form to expect an array for the value submitted and the element will not work properly without it. NOTE: Single level arrays such as multiple value elements:

1
<input type="checkbox" name="toppings[]" />
<input type="checkbox" name="toppings[]" />

DO NOT need the setIsArray(true); code. One level deeper than that and things will not work (the value will not be passed correctly to the form element so it may appear blank in the email) and you WILL NEED to use setIsArray(true);.

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy