Skip to content

Commit

Permalink
Adds field->optionsDefinition() as "options as definition"
Browse files Browse the repository at this point in the history
Method is a placeholder can't really think of a better name at this point
  • Loading branch information
daftspunk committed Sep 2, 2024
1 parent 843dc3e commit 96f1583
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Element/Form/FieldDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 11 additions & 1 deletion src/Element/Form/FieldOptionDefinition.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace October\Rain\Element;
<?php namespace October\Rain\Element\Form;

/**
* FieldOptionDefinition represents a single option that can be associated to an field field
Expand Down Expand Up @@ -32,4 +32,14 @@ protected function initDefaultValues()
->disabled(false)
->comment('');
}

/**
* useOptionConfig
*/
public function useOptionConfig(array $config): FieldOptionDefinition
{
// process option as documented

return $this;
}
}

0 comments on commit 96f1583

Please sign in to comment.