2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-09-13 22:41:22 +00:00

Create new stock item

This commit is contained in:
Oliver
2021-08-15 14:44:40 +10:00
parent a09d0b6887
commit 3fb6b38930
4 changed files with 78 additions and 2 deletions

View File

@@ -154,6 +154,9 @@ class APIFormField {
return _constructBoolean();
case "related field":
return _constructRelatedField();
case "float":
case "decimal":
return _constructFloatField();
case "choice":
return _constructChoiceField();
default:
@@ -203,6 +206,34 @@ class APIFormField {
);
}
// Construct a floating point numerical input field
Widget _constructFloatField() {
return TextFormField(
decoration: InputDecoration(
labelText: required ? label + "*" : label,
labelStyle: _labelStyle(),
helperText: helpText,
helperStyle: _helperStyle(),
hintText: placeholderText,
),
initialValue: (value ?? 0).toString(),
keyboardType: TextInputType.numberWithOptions(signed: true, decimal: true),
validator: (value) {
double? quantity = double.tryParse(value.toString()) ?? null;
if (quantity == null) {
return L10().numberInvalid;
}
},
onSaved: (val) {
data["value"] = val;
},
);
}
// Construct an input for a related field
Widget _constructRelatedField() {