name, array('control' => $this->formControl)); $children = $this->element->children(); $subForm->load($children); $subForm->setFields($children); // And finaly build a main container $str = array(); $values = $this->value; // explode to array if string if (is_string($values)) { $values = explode(',', $values); } $fields = $subForm->getFieldset(); $str[] = '
'; foreach ($values as $value) { $class = ''; // highlight grouped fields if (count($fields) > 1) { $class = ' well well-small p-4 bg-light'; } $str[] = '
'; $str[] = '
'; $n = 0; foreach ($fields as $field) { $field->element['multiple'] = true; // substitute for repeatable element $field->element['name'] = (string) $this->element['name']; if (is_array($value)) { $value = isset($value[$n]) ? $value[$n] : $value[0]; } // escape value $field->value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); $field->setup($field->element, $field->value, $this->group); // reset id $field->id .= '_' . $n; if (strpos($field->name, '[]') === false) { $field->name .= '[]'; } $str[] = $field->renderField(array('description' => $field->description)); $n++; } $str[] = '
'; $str[] = '
'; $str[] = ' '; $str[] = ' '; $str[] = '
'; $str[] = '
'; } $str[] = '
'; return implode("", $str); } }