molecule_input
Displays a molecule sketcher widget and maps its value to the backend as a string + toolkit.Molecule
object.
Basic use¶
{% molecule_input %}
from simmate.website.core_components.components import (
DynamicFormComponent,
MoleculeInput,
)
class CortevaTargetFormView(DynamicFormComponent, MoleculeInput):
class Meta:
javascript_exclude = (
*DynamicFormComponent.Meta.javascript_exclude,
*MoleculeInput.Meta.javascript_exclude,
)
Parameters¶
Parameter | Description |
---|---|
name |
The unique name or identifier for the input field. This should match the name of your class attribute in the backend. Type: str , Default: — |
label |
The display label for the input field. If not provided, the name may be used as the label.Type: str , Default: None |
show_label |
Whether to display the label alongside the input field. Type: bool , Default: True |
help_text |
Optional helper text to be shown alongside the input field. Type: str , Default: None |
load_button |
Whether to display a button that loads the molecule from the sketcher and the replaces the sketcher with the molecule image. Type: str , Default: None |
set_molecule_method |
Name of the method that parses the molecule and sets the python class attribute. Type: str , Default: None |
many_molecules |
Whether to allow input of multiple molecules (e.g., as a list or batch input). Type: bool , Default: False |
For the molecule sketcher:
Parameter | Description |
---|---|
allow_sketcher_input |
Whether to allow molecule input via a sketcher widget. Type: bool , Default: True |
sketcher_input_label |
The label to display above the sketcher input. Type: str , Default: "Draw Molecule" |
For the text input area:
Parameter | Description |
---|---|
allow_text_input |
Whether to allow molecule input via a text area (e.g., SMILES, mol block). Type: bool , Default: False |
text_input_name |
The unique name or identifier for the text input field. If not provided, defaults to name + _text .Type: str , Default: None |
text_input_label |
The label to display above the text input area. Type: str , Default: "Paste Molecule Text" |
For the "custom input" area (e.g., IDs from other table):
Parameter | Description |
---|---|
allow_custom_input |
Whether to allow a custom input field (e.g., for IDs or external references). Type: bool , Default: False |
custom_input_name |
The unique name or identifier for the custom input field. If not provided, defaults to name + _custom .Type: str , Default: None |
custom_input_label |
The label to display above the custom input field. Type: str , Default: "Custom Input" |
custom_input_placeholder |
Placeholder text for the custom input field. Type: str , Default: "12345" |