Skip to content

Commit

Permalink
Merge pull request #72 from forkcms/1-4-5-base
Browse files Browse the repository at this point in the history
Cast numeric values to strings
  • Loading branch information
StijnVrolijk authored Jul 19, 2019
2 parents 7af722a + 85f20a4 commit 6e1e4dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spoon/form/radiobutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ public function parse(SpoonTemplate $template = null)
$element = array();
$element[$name] = '<input type="radio" name="' . $this->name . '" value="' . $value . '"';

// if the form uses numeric values, PHP will automatically cast them to integers because we set them as array keys
// if we don't cast it back to a string we will compare an integer to a string and it will always fail
if (is_numeric($value) && is_string($this->getChecked())) {
$value = (string) $value;
}

// checked status
if($value === $this->getChecked()) $element[$name] .= ' checked="checked"';

Expand Down

0 comments on commit 6e1e4dc

Please sign in to comment.