diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/App.php | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/App.php b/src/App.php index 107113a..a155017 100644 --- a/src/App.php +++ b/src/App.php @@ -171,9 +171,7 @@ class App throw new \Exception('Form has no page ' . $page); } - foreach ($parsed['page'][$page]['field'] as $key => $field) { - $fields[$key] = $this->buildSingleField($formPath, $key, $field); - } + $fields = $this->buildSinglePageFields($parsed['page'][$page], $formPath); } // else get all fields @@ -182,9 +180,7 @@ class App if (isset($parsed['page'])) { $pages = $parsed['page']; foreach ($pages as $pageKey => $pageFields) { - foreach ($pageFields['field'] as $key => $field) { - $fields[$pageKey][$key] = $this->buildSingleField($formPath, $key, $field); - } + $fields[$pageKey] = $this->buildSinglePageFields($pageFields, $formPath); } } @@ -200,6 +196,25 @@ class App } /** + * @param array $pageFields + * @param string $formPath + */ + public function buildSinglePageFields($pageFields, $formPath) + { + $fields = []; + + if (! empty($pageFields['file'])) { + $pageFields = array_replace_recursive($pageFields, Toml::parseFile($formPath . '/fields/' . $pageFields['file'])); + } + + foreach ($pageFields['field'] as $key => $field) { + $fields[$key] = $this->buildSingleField($formPath, $key, $field); + } + + return $fields; + } + + /** * @param string $formPath * @param string $key * @param string $field |