pdwidgets.widgets.form

Form binder: named fields, validate / values / commit (no chrome of its own).

class pdwidgets.widgets.form.Form(on_commit=None, error_label=None)[source]

Bases: object

Register named field widgets and collect/validate their values.

Depends on existing controls (FormRow, TextInput, Switch, …). Optional error_label receives the first error string when validate fails.

add(name, widget, validator=None)[source]

Bind widget under name; optional validator(value) -> err|None.

get(name)[source]

Return the widget registered as name, or None.

values()[source]

Return {name: widget.value} for all registered fields.

validate()[source]

Run validators; return {name: error_str} (empty if ok).

Updates error_label.value with the first error when present.

commit()[source]

Validate then invoke on_commit(values) when valid.

Returns:

bool – True if validation passed (and commit ran).