User tests: Successful: Unsuccessful:
Pull Request resolves #48485.
In Joomla\CMS\Form\Field\MeterField:
MeterField::setup() previously extracted attributes like width, color, active, and animated from $this->element, but omitted min and max. As a result, custom min and max attributes defined in form XML were ignored and $this->min / $this->max remained at their default values (0 and 100).MeterField::__get() did not include min and max in its switch statement, returning null when accessing $field->min or $field->max (despite __set() supporting them).layouts/joomla/form/field/meter.php), aria-valuemin and aria-valuemax and the width percentage calculation (((float) ($value - $min) * 100) / ($max - $min)) always operated on 0..100 instead of the configured range.This PR:
min and max attributes in MeterField::setup().min and max to the switch statement in MeterField::__get().tests/Unit/Libraries/Cms/Form/Field/MeterFieldTest.php.Run PHPUnit:
libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Form/Field/MeterFieldTest.phpmin and max on a meter field (e.g. 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, $field->max, and the rendered HTML.$field->min and $field->max return null.aria-valuemin="0", aria-valuemax="100", and style="width:30%;" (calculated from 0..100).$field->min returns 10, and $field->max returns 50.aria-valuemin="10", aria-valuemax="50", and style="width:50%;" (calculated as (30 - 10) * 100 / (50 - 10)).Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Signed-off-by: bhuvan-somisetty somisettybhuvan5@gmail.com
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries Unit Tests |
I have tested this item ✅ successfully on 12e7d63
I have tested this item ✅ successfully on 12e7d63
I have tested this item ✅ successfully on 12e7d63
| Status | Pending | ⇒ | Ready to Commit |
RTC
RTC
I have tested this item ✅ successfully on 12e7d63
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48486.