summaryrefslogtreecommitdiff
path: root/src/Controllers/FieldsController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controllers/FieldsController.php')
-rw-r--r--src/Controllers/FieldsController.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Controllers/FieldsController.php b/src/Controllers/FieldsController.php
new file mode 100644
index 0000000..c407604
--- /dev/null
+++ b/src/Controllers/FieldsController.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace FlatFileForms\Controllers;
+
+use FlatFileForms\Builder;
+
+class FieldsController
+{
+ public function getFields(Builder $builder): array
+ {
+ /**@var Utilities $utilities*/
+ global $utilities;
+
+ $fields = $builder->buildFields($_GET['page'] ?? null);
+
+ // flatten paged form
+ if ($utilities->isPagedFieldSet($fields) && isset($_GET['flat'])) {
+ $fields = array_merge(...array_values($fields));
+ }
+
+ $content['data'] = $fields;
+
+ return $content;
+ }
+}