Ticket #496 (closed defect: fixed)

Opened 15 years ago

Last modified 14 years ago

Int/Long/Float widgets do not handle empty values

Reported by: atchertchian Owned by: fguillaume
Priority: P2 Milestone: CPS 3.4.0
Component: CPSSchemas Version: unspecified
Severity: normal Keywords: widgets

Description (last modified by fguillaume) (diff)

Int/Long/Float? widgets do not handle empty values

Int and Float widget validation methods do not take care of the is_required property. Long widget takes care of it, but if it is not required and value is empty, the value is casted as a long integer so the empty value is not accepted. If value is empty, it should be set to a zero value.

Moreover, I would find it useful if, when validation is ok, datastructure was updated to store the integer/long/float value instead of keeping the corresponding string value. But maybe there is a reason not do do this?

Change History

comment:1 Changed 15 years ago by fguillaume

  • Cc fg@… added

The datastructure always contains what comes/goes to the browser, which means always strings (or File/FileUpload? objects).

comment:2 Changed 14 years ago by fguillaume

  • Description modified (diff)
  • Milestone changed from unspecified to CPS 3.4.0

comment:3 Changed 14 years ago by lregebro

Empty and zero are two different things. If we can't store an empty value (None) we shouldn't really allow you to enter an empty value. Converting it to 0 is therefore not the correct thing to do if the widget gets an empty string.

comment:4 Changed 14 years ago by fguillaume

  • Status changed from new to assigned
  • Owner changed from trac to fguillaume

comment:5 Changed 14 years ago by fguillaume

  • Status changed from assigned to closed
  • Resolution set to fixed

Fixed in [30139]. I decided to store None if the widget is not required.

comment:6 Changed 14 years ago by fguillaume

And [30144] too for Float Widget.

Note: See TracTickets for help on using tickets.