Commit f3aba9a2 authored by Michael Strong's avatar Michael Strong

Merge branch 'bugfix-numeric-field-extension' into 'master'

This merge will enable negative value validations to succeed when zero is the minimum applied

See merge request !45
parents bcb37212 7db76b75
......@@ -26,10 +26,10 @@ class EditableNumericFieldExtension extends DataExtension
$def['type'] = 'text-number';
// Numeric validation
if(!empty($this->owner->MinValue)) {
if(is_numeric($this->owner->MinValue)) {
$def['min'] = (int)$this->owner->MinValue;
}
if(!empty($this->owner->MaxValue)) {
if(is_numeric($this->owner->MaxValue)) {
$def['max'] = (int)$this->owner->MaxValue;
}
......@@ -42,4 +42,4 @@ class EditableNumericFieldExtension extends DataExtension
}
}
}
\ No newline at end of file
}
......@@ -83,6 +83,21 @@ class FormFieldDefinitionTest extends SapphireTest
'showOnLoad' => true,
'unitLabel' => 'Units!'
), $def);
// Test numeric's min value with zero input
$numericField->MinValue = 0;
$def = $numericField->getFieldDefinition();
$this->assertEquals(array(
'id' => 'numericField',
'label' => 'Test numeric field',
'type' => 'text-number',
'min' => 0,
'max' => 100,
'responsiveLabel' => null,
'errorText' => 'This is a required field.',
'showOnLoad' => true,
'unitLabel' => 'Units!'
), $def);
}
public function test_RadioField_getFieldDefinition()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment