Using foreach loop for `$instance` of form and update array widget iteration

Using foreach loop for `$instance` of form and update array widget iteration