q2_sdk.ui.forms — Embed frontend code into Q2 Online

For an in context view of these classes, check out the guide at Q2 Forms.

class q2_sdk.ui.forms.Q2Form(header, list_of_rows=None, custom_template='', hide_submit_button=False, submit_label='Submit', clear_button_label=None, modal=None, custom_javascript='', routing_key='')[source]

Bases: object

A basic Q2-styled form. Assumes that it is running inside a Q2 environment and that certain styles and JavaScript elements are present.

This already provides the <form id=”sdkForm”> element, injecting your custom code inside of it.

Guaranteed to render correctly and match the Q2 online environment’s look and feel, so is useful for basic forms or as a starting place for iterating on something more complex.

Parameters:
  • header (str) – If populated, is rendered as an <h1> at the top of the page

  • list_of_rows – (Deprecated. Prefer HTML in custom_template) Rows which in turn contain fields

  • custom_template (str) – HTML to inject inside the provided shell

  • hide_submit_button – If True, this form will not have a submit button

  • submit_label – Text of the submit button

  • clear_button_label – Text of the clear button. If blank, no button will appear

  • modal (Union[SuccessModal, ErrorModal, WarningModal]) – If provided, ties into Q2’s existing javascript to display a modal over the form

  • custom_javascript – If provided, will be run after the rest of the form renders

  • routing_key – Creates a hidden input named routing_key which can be used by the extension to determine what step to run next of a multi-step flow.

serialize()[source]

Generates self.template_name with attributes of current instance

Return type:

str

class q2_sdk.ui.forms.AuthToken[source]

Bases: TypedDict

key: str
value: str
class q2_sdk.ui.forms.Q2TectonForm(header, auth_tokens, tecton_version, base_assets_url, extension_name, form_id=None, defer_fetching_stop=False, head_content='', foot_content='', custom_javascript='', routing_key='', custom_template='', hide_submit_button=False, submit_label='Submit', clear_button_label=None, tecton_beta=False, page_padding=True, load_platform_css=True, load_utilities=True, load_elements=True, load_default_theme=True, modal=None)[source]

Bases: Q2Form

Inherits from Q2Form, but adds several options for working with Tecton enabled environments.

It is possible to use this directly, but typically will be invoked by calling self.get_tecton_form from your Tecton Server Side Rendered extension

Parameters:
  • header (str) – If populated, is rendered as an <h1> at the top of the page

  • q2token – SessionId Used to authenticate back through the Q2 system

  • tecton_version (str) – Tecton url which will be dynamically imported in a <script> tag

  • base_assets_url (str) – Where the Python server is serving up the assets (typically <root>:<port>/<extension>/assets)

  • extension_name (str) – Used for calling back to the backend

  • form_id (Optional[int]) – id attribute of the <form> element

  • defer_fetching_stop (bool) – By default the loading spinner will go away once the form is loaded. Setting this to True allows supresses that.

  • head_content (str) – HTML injected into the <head> tag

  • foot_content (str) – HTML injected at the bottom of the <html> tag

  • custom_javascript (str) – If provided, will be run after the rest of the form renders

  • routing_key (str) – Creates a hidden input named routing_key which can be used by the extension to determine what step to run next of a multi-step flow.

  • custom_template (str) – HTML to inject inside the provided shell

  • hide_submit_button (bool) – If True, this form will not have a submit button

  • submit_label (str) – Text of the submit button

  • clear_button_label (Optional[str]) – Text of the clear button. If blank, no button will appear

  • modal (Union[SuccessModal, ErrorModal, WarningModal, None]) – If provided, ties into Q2’s existing javascript to display a modal over the form

class q2_sdk.ui.forms.Q2SingleSignOn(header, sso_url, use_viewport_height=False, **kwargs)[source]

Bases: Q2Form

(Deprecated. Prefer SSO extension_type since 2.19.0)

For embedding an external site in an iframe within the Q2 Online environment

Parameters:
  • header – Displays on mobile devices

  • sso_url (str) – URL of the content server

  • use_viewport_height (bool) – If True, will set the bottom of the iframe to the height of the left nav menu