def form(self): """ The form configuration (lazy property), fallback cascade: 1. the form specified in constructor 2. "mobile_form" config 3. "crud_form" config 4. all readable fields @returns: an S3SQLForm instance """ form = self._form if form is None: resource = self.resource form = resource.get_config("mobile_form") if form is None: form = resource.get_config("crud_form") if form is None: # Construct a custom form from all readable fields readable_fields = self.resource.readable_fields() fields = [ field.name for field in readable_fields if field.type != "id" ] form = S3SQLCustomForm(*fields) self._form = form return form
def mobile_form(resource): """ Get the mobile form for a resource @param resource: the S3Resource @returns: an S3SQLForm instance """ # Get the form definition from "mobile_form" table setting form = resource.get_config("mobile_form") if form is None: # Fallback form = resource.get_config("crud_form") # @todo: if resource is a dynamic table, establish # the mobile form from the "form" table setting # before falling back to all readable fields if not form: # No mobile form configured, or is a S3SQLDefaultForm # => construct a custom form that includes all readable fields readable_fields = resource.readable_fields() fields = [ field.name for field in readable_fields if field.type != "id" ] form = S3SQLCustomForm(*fields) return form
def mobile_form(resource): """ Get the mobile form for a resource @param resource: the S3Resource @returns: an S3SQLForm instance """ # Get the form definition from "mobile_form" table setting form = resource.get_config("mobile_form") if not form or not isinstance(form, S3SQLCustomForm): # Fallback form = resource.get_config("crud_form") if not form: # No mobile form configured, or is a S3SQLDefaultForm # => construct a custom form that includes all readable fields readable_fields = resource.readable_fields() fields = [field.name for field in readable_fields if field.type != "id"] form = S3SQLCustomForm(*fields) return form