Package s3 :: Module s3forms :: Class S3SQLInlineLink
[frames] | no frames]

Class S3SQLInlineLink

source code

      object --+            
               |            
S3SQLFormElement --+        
                   |        
        S3SQLSubForm --+    
                       |    
    S3SQLInlineComponent --+
                           |
                          S3SQLInlineLink


Subform to edit link table entries for the master record

Constructor options:

    ** Common options:

    readonly..........True|False......render read-only always
    multiple..........True|False......allow selection of multiple
                                      options (default True)
    widget............string..........which widget to use, one of:
                                      - multiselect (default)
                                      - groupedopts (default when cols is specified)
                                      - hierarchy   (requires hierarchical lookup-table)
                                      - cascade     (requires hierarchical lookup-table)
    render_list.......True|False......in read-only mode, render HTML
                                      list rather than comma-separated
                                      strings (default False)

    ** Options for groupedopts widget:

    cols..............integer.........number of columns for grouped
                                      options (default: None)
    orientation.......string..........orientation for grouped options
                                      order, one of:
                                          - cols
                                          - rows
    size..............integer.........maximum number of items per group
                                      in grouped options, None to disable
                                      grouping
    sort..............True|False......sort grouped options (always True
                                      when grouping, i.e. size!=None)
    help_field........string..........additional field in the look-up
                                      table to render as tooltip for
                                      grouped options
    table.............True|False......render grouped options as HTML
                                      TABLE rather than nested DIVs
                                      (default True)

    ** Options for multi-select widget:

    header............True|False......multi-select to show a header with
                                      bulk-select options and optional
                                      search-field
    search............True|False......show the search-field in the header
    selectedList......integer.........how many items to show on multi-select
                                      button before collapsing into number
    noneSelectedText..string..........placeholder text on multi-select button
    columns...........integer.........Foundation column-width for the
                                      widget (for custom forms)

    ** Options-filtering:
       - multiselect and groupedopts only
       - for hierarchy and cascade widgets, use the "filter" option

    requires..........Validator.......validator to determine the
                                      selectable options (defaults to
                                      field validator)
    filterby..........field selector..filter look-up options by this field
                                      (can be a field in the look-up table
                                      itself or in another table linked to it)
    options...........value|list......filter for these values, or:
    match.............field selector..lookup the filter value from this
                                      field (can be a field in the master
                                      table, or in linked table)

    ** Options for hierarchy and cascade widgets:

    levels............list............ordered list of labels for hierarchy
                                      levels (top-down order), to override
                                      the lookup-table's "hierarchy_levels"
                                      setting, cascade-widget only
    represent.........callback........representation method for hierarchy
                                      nodes (defaults to field represent)
    leafonly..........True|False......only leaf nodes can be selected
    cascade...........True|False......automatically select the entire branch
                                      when a parent node is newly selected;
                                      with multiple=False, this will
                                      auto-select single child options
                                      (default True when leafonly=True)
    filter............resource query..filter expression to filter the
                                      selectable options

Instance Methods
 
extract(self, resource, record_id)
Get all existing links for record_id.
source code
 
__call__(self, field, value, **attributes)
Widget renderer, currently supports multiselect (default), hierarchy and groupedopts widgets.
source code
 
validate(self, form)
Validate this link, currently only checking whether it has a value when required=True
source code
 
accept(self, form, master_id=None, format=None)
Post-processes this subform element against the POST data, and create/update/delete any related records.
source code
 
represent(self, value)
Read-only representation of this subform.
source code
 
get_options(self)
Get the options for the widget
source code
 
get_link(self)
Find the target component and its linktable
source code

Inherited from S3SQLInlineComponent: parse, resolve

Inherited from S3SQLFormElement: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  prefix = "link"
Properties

Inherited from object: __class__

Method Details

extract(self, resource, record_id)

source code 

Get all existing links for record_id.

Parameters:
  • resource - the resource the record belongs to
  • record_id - the record ID
Returns:
list of component record IDs this record is linked to via the link table
Overrides: S3SQLSubForm.extract

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

source code 

Widget renderer, currently supports multiselect (default), hierarchy and groupedopts widgets.

Parameters:
  • field - the input field
  • value - the value to populate the widget
  • attributes - attributes for the widget
Returns:
the widget
Overrides: S3SQLSubForm.__call__

validate(self, form)

source code 

Validate this link, currently only checking whether it has a value when required=True

Parameters:
  • form - the form

accept(self, form, master_id=None, format=None)

source code 

Post-processes this subform element against the POST data, and create/update/delete any related records.

Parameters:
  • form - the master form
  • master_id - the ID of the master record in the form
  • format - the data format extension (for audit)
Returns:
True on success, False on error
Overrides: S3SQLSubForm.accept

To Do: implement audit

represent(self, value)

source code 

Read-only representation of this subform.

Parameters:
  • value - the value as returned from extract()
Returns:
the read-only representation
Overrides: S3SQLSubForm.represent

get_options(self)

source code 

Get the options for the widget

Returns:
dict {value: representation} of options

get_link(self)

source code 

Find the target component and its linktable

Returns:
tuple of S3Resource instances (component, link)

Class Variable Details

prefix

Value:
"link"