public function render(Form $form, $errors) { $fields = []; // sort fields by 'position' sort_children($form->fields); foreach ($form->fields as $field => $data) { $fields[] = $this->renderer->render($field, $data, $errors->get($field)); } return view($form->template ?: $this->template)->with('options', $form->options)->with('fields', $fields)->render(); }
function sort_children(&$album) { if (isset($album['children']) && $album['count']) { foreach ($album['children'] as &$child) { sort_children($child); } TreeSorter::sort($album['children'], $album['sort']); } }