Skip to content

Commit

Permalink
Improve support for BackedEnums
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeTowers committed Jan 10, 2024
1 parent c383197 commit 412b324
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/backend/classes/FormField.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php namespace Backend\Classes;
<?php

use Str;
namespace Backend\Classes;

use BackedEnum;
use Html;
use Winter\Storm\Database\Model;
use Winter\Storm\Html\Helper as HtmlHelper;
use Winter\Storm\Support\Str;

/**
* Form Field definition
Expand Down Expand Up @@ -370,7 +373,10 @@ public function isSelected($value = true)
return false;
}

return (string) $value === (string) $this->value;
$value = ($value instanceof BackedEnum) ? $value->value : $value;
$currentValue = ($this->value instanceof BackedEnum) ? $this->value->value : $this->value;

return (string) $value === (string) $currentValue;
}

/**
Expand Down

0 comments on commit 412b324

Please sign in to comment.