meter field with custom min and max attributes (for example min="10", max="50", value="30"):<field
name="my_meter"
type="meter"
label="Usage Meter"
min="10"
max="50"
value="30"
/>$form = new \Joomla\CMS\Form\Form('test');
$form->load('<form><field name="my_meter" type="meter" label="Usage Meter" min="10" max="50" value="30" /></form>');
$field = $form->getField('my_meter');
echo $form->getInput('my_meter');$field->min and $field->max.5.4
MeterField::setup() reads min and max from the XML element attributes ($this->min = 10, $this->max = 50).$field->min and $field->max return 10 and 50.aria-valuemin="10", aria-valuemax="50", aria-valuenow="30", and width calculated as 50% ((30 - 10) * 100 / (50 - 10)).MeterField::setup() ignores min and max XML attributes, leaving $this->min hardcoded to 0 and $this->max hardcoded to 100.MeterField::__get() does not handle min and max, returning null when accessing $field->min or $field->max.aria-valuemin="0", aria-valuemax="100", and width 30% ((30 - 0) * 100 / (100 - 0)).In libraries/src/Form/Field/MeterField.php:
setup(), attributes width, color, active, and animated are extracted from $this->element, but min and max are omitted:if ($return) {
$this->width = isset($this->element['width']) ? (string) $this->element['width'] : '';
$this->color = isset($this->element['color']) ? (string) $this->element['color'] : '';
// $this->min and $this->max are never extracted__get(), min and max are missing from the switch statement (even though they are present in __set()):public function __get($name)
{
switch ($name) {
case 'active':
case 'width':
case 'animated':
case 'color':
return $this->$name;
}
return parent::__get($name);
}Adding min and max extraction in setup() and handling them in __get() resolves the issue.
| Labels |
Added:
No Code Attached Yet
|
||
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-10-12 14:47:51 |
| Closed_By | ⇒ | chmst |
Tested and RTC. Thank you!
Tested and PR is RTC. Thank you!
bug confirmed
as you have a fix please submit a pull request