public function findFormFields($type, $fields, $found_fields = [])
{
foreach ($fields as $key => $field) {
if (isset($field['type']) && $field['type'] == $type) {
$found_fields[$key] = $field;
} elseif (isset($field['fields'])) {
$result = $this->findFormFields($type, $field['fields'], $found_fields);
if (!empty($result)) {
$found_fields = array_merge($found_fields, $result);
}
}
}
return $found_fields;
}