Skip to content

Commit

Permalink
Merge pull request #554 from ColonelThirtyTwo/fix-float-extra-field-i…
Browse files Browse the repository at this point in the history
…nput

Fix number extra field not accepting decimals
  • Loading branch information
chrismaddalena authored Nov 22, 2024
2 parents b35f8db + 05776e4 commit 311182d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ghostwriter/commandcenter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ class ExtraFieldType(NamedTuple):
# Returns an "empty" value
empty_value: Callable[[], Any]

def float_widget(*args, **kwargs):
widget = forms.widgets.NumberInput(*args, **kwargs)
widget.attrs.setdefault("step", "any")
return widget

EXTRA_FIELD_TYPES = {
"checkbox": ExtraFieldType(
Expand Down Expand Up @@ -390,7 +394,7 @@ class ExtraFieldType(NamedTuple):
"float": ExtraFieldType(
display_name="Number",
form_field=lambda *args, **kwargs: forms.FloatField(required=False, *args, **kwargs),
form_widget=forms.widgets.NumberInput,
form_widget=float_widget,
from_str=float,
empty_value=lambda: 0.0,
),
Expand Down

0 comments on commit 311182d

Please sign in to comment.