Skip to content

Commit

Permalink
Fixes #5093 - True/False labels on <select> options.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Nov 1, 2023
1 parent fb98771 commit faa2f8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions e107_handlers/form_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3597,10 +3597,11 @@ public function option($option_title, $value, $selected = false, $options = '')

$options = $this->format_options('option', '', $options);
$options['selected'] = $selected; //comes as separate argument just for convenience

$ltitle = strtolower($option_title);
$label = ($ltitle === 'true' || $ltitle === 'false') ? $option_title : defset($option_title, $option_title);

return "<option" . $this->attributes(['value' => $value]) . $this->get_attributes($options) . '>'
. defset($option_title, $option_title) .
. $label .
'</option>';
}

Expand Down
8 changes: 8 additions & 0 deletions e107_tests/tests/unit/e_formTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ public function testOption()

$this->assertEquals($expected, $actual);

$tests = ['true'=>'True', 'false'=>'False', 'legacy'=>'Legacy'];

foreach($tests as $k=>$v)
{
$expected = "<option value='$k'>$v</option>";
$result = $this->_frm->option($v,$k);
$this->assertSame($expected, $result);
}
}

public function testOption_multi()
Expand Down

0 comments on commit faa2f8a

Please sign in to comment.