Package s3 :: Module s3widgets :: Class S3TagCheckboxWidget
[frames] | no frames]

Class S3TagCheckboxWidget

source code

??-286 --+
         |
        S3TagCheckboxWidget


Simple widget to use a checkbox to toggle a string-type Field
between two values (default "Y"|"N").
Like an S3BooleanWidget but real Booleans cannot be stored in strings.
Designed for use with tag.value

NB it is usually better to use a boolean Field with a context-specific
   representation function than this.

NB make sure the field validator accepts the configured on/off values,
   e.g. IS_IN_SET(("Y", "N")) (also for consistency with imports)

NB when using this with a filtered key-value-component (e.g.
   pr_person_tag), make the filtered component multiple=False and
   embed *.value as subtable-field (do not use S3SQLInlineComponent)

Instance Methods
 
__init__(self, on="Y", off="N")
Constructor
source code
 
__call__(self, field, value, **attributes)
Widget construction
source code
 
requires(self, value)
Input-validator to convert the checkbox value into the corresponding tag value
source code
Method Details

__init__(self, on="Y", off="N")
(Constructor)

source code 

Constructor

Parameters:
  • on - the value of the tag for checkbox=on
  • off - the value of the tag for checkbox=off

__call__(self, field, value, **attributes)
(Call operator)

source code 

Widget construction

Parameters:
  • field - the Field
  • value - the current (or default) value
  • attributes - overrides for default attributes

requires(self, value)

source code 

Input-validator to convert the checkbox value into the corresponding tag value

Parameters:
  • value - the checkbox value ("on" if checked)