Skip to content

Commit

Permalink
Take value as label by default
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Oct 8, 2024
1 parent 9d82cb1 commit 38750a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/Element/Filter/ScopeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ public function asOptionsDefinition($options = null)
$result = [];

foreach ($options as $value => $option) {
$definition = (new OptionDefinition)
->value($value)
->useOptionConfig($option);

$result[$value] = $definition;
$result[$value] = (new OptionDefinition)->useOptionConfig($value, $option);
}

return $result;
Expand Down
6 changes: 1 addition & 5 deletions src/Element/Form/FieldDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ public function asOptionsDefinition($options = null)
$result = [];

foreach ($options as $value => $option) {
$definition = (new OptionDefinition)
->value($value)
->useOptionConfig($option);

$result[$value] = $definition;
$result[$value] = (new OptionDefinition)->useOptionConfig($value, $option);
}

return $result;
Expand Down
8 changes: 4 additions & 4 deletions src/Element/OptionDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ protected function initDefaultValues()
/**
* useOptionConfig
*/
public function useOptionConfig($option): OptionDefinition
public function useOptionConfig($value, $option = null): OptionDefinition
{
$this->value($value)->label($value);

if (!is_array($option)) {
$this->label($option);
return $this;
Expand Down Expand Up @@ -83,9 +85,7 @@ protected function evalChildOptions(array $children): array
$result = [];

foreach ($children as $value => $option) {
$result[$value] = (new OptionDefinition)
->value($value)
->useOptionConfig($option);
$result[$value] = (new OptionDefinition)->useOptionConfig($value, $option);
}

return $result;
Expand Down

0 comments on commit 38750a9

Please sign in to comment.