summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-01-05 17:05:10 +0100
committerDaniel Weipert <code@drogueronin.de>2022-01-10 11:29:13 +0100
commit43ec8517cbc42093ad1f17063495f79e6eddf1cf (patch)
tree63394e9d41c1f3a5b1dfd85c02a30bb2241f3844 /src
parent47e6d88484eba2733551de9edde8c4ac58706e5e (diff)
Build pages with file fields
Diffstat (limited to 'src')
-rw-r--r--src/App.php27
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