-
Notifications
You must be signed in to change notification settings - Fork 919
Open
Open
Copy link
Labels
enhancementNew feature or requestNew feature or request
Description
Description
I have a form at the top of my notebook that is referenced in various places throughout the notebook. My two options are currently:
- Reference
input_form.value["key"]and have "errors" throughout the code until the button is pressed. - In every cell that uses the form, also have
mo.stop(input_form.value is None, "Please complete form")beforehand, which is slightly cumbersome.
It would be good if there was a way to configure the form so that it skips the dependent cells automatically.
If I were writing only a couple of apps then it wouldn't be a problem. But we're likely going to have hundreds, all with a similar form at the top.
Suggested solution
Ideally this could be configured from mo.ui.form(...):
- With a
stop_cell_execution: bool = Falseargument. The 'stop' message could be based on the label. - With a
stop_cell_execution_message: str | None = Noneargument that if a string, stops execution. - Or with both.
- (Or maybe this could even be the default?)
Are you willing to submit a PR?
- Yes
Alternatives
I've tried wrapping the form.
class InputGetter:
def __init__(self, ui_element: mo.ui.form):
self.ui_element = ui_element
@property
def value(self) -> dict[str, Any]:
mo.stop(self.ui_element.value is None, self.msg)
assert self.ui_element.value is not None
return self.ui_element.valueThis does wonders for the output of the downstream cells. But Marimo loses the reference, and doesn't know to make downstream cells stale when the form is submitted.
Thanks!
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request