From 96f1583f5deb3faa746a099f18699c7f8811dc2c Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 2 Sep 2024 15:11:38 +1000 Subject: [PATCH] Adds field->optionsDefinition() as "options as definition" Method is a placeholder can't really think of a better name at this point --- src/Element/Form/FieldDefinition.php | 18 ++++++++++++++++++ src/Element/Form/FieldOptionDefinition.php | 12 +++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Element/Form/FieldDefinition.php b/src/Element/Form/FieldDefinition.php index 94e12b868..1c441406a 100644 --- a/src/Element/Form/FieldDefinition.php +++ b/src/Element/Form/FieldDefinition.php @@ -144,6 +144,24 @@ public function options($value = null) return $this; } + /** + * optionsDefinition + */ + public function optionsDefinition() + { + $options = $this->options(); + + $result = []; + + foreach ($options as $key => $option) { + $definition = new FieldOptionDefinition; + $definition->useOptionConfig($option); + $result[$key] = $definition; + } + + return $result; + } + /** * matchesContext returns true if the field matches the supplied context */ diff --git a/src/Element/Form/FieldOptionDefinition.php b/src/Element/Form/FieldOptionDefinition.php index 8531e2690..065b0c67e 100644 --- a/src/Element/Form/FieldOptionDefinition.php +++ b/src/Element/Form/FieldOptionDefinition.php @@ -1,4 +1,4 @@ -disabled(false) ->comment(''); } + + /** + * useOptionConfig + */ + public function useOptionConfig(array $config): FieldOptionDefinition + { + // process option as documented + + return $this; + } }