Symple module

Form

Interactive form with pages, sections, and fields for command data exchange.

Form

#include <icy/symple/form.h>

Inherits: FormElement

Interactive form with pages, sections, and fields for command data exchange.

Attach a Form to a Command message to carry structured input/output. The action field governs the exchange direction; partial enables live/auto-complete field submission.

Public Methods

ReturnNameDescription
FormConstructs an unbound form (root pointer is null).
FormConstructs a form bound to the given JSON node. Sets the type field to "form".
FormConstructs a form from a Command, binding to command["form"]. Sets the type field to "form".
boolvalidReturns true if the element is valid, non-empty, and has no errors.
std::stringaction constReturns the form action string (defaults to "form").
boolpartial constReturns true if this is a partial form submission.
voidsetActionSets the form action field. Throws std::invalid_argument for unrecognised values. Possible values: form - Form-processing entity requests form completion. submit - Form-submitting entity is sending data. cancel - Form-submitting entity cancelled submission. result - Form-processing entity is returning data.
voidsetPartialMarks the form as a partial section for live/auto-complete updates. Partial forms transmit only the changed fields rather than the entire form payload.

Form

Form()

Constructs an unbound form (root pointer is null).


Form

Form(json::Value & root)

Constructs a form bound to the given JSON node. Sets the type field to "form".

Parameters

  • root JSON node to bind to.

Form

Form(Command & root)

Constructs a form from a Command, binding to command["form"]. Sets the type field to "form".

Parameters

  • root Parent command message.

valid

bool valid()

Returns true if the element is valid, non-empty, and has no errors.


action

const

std::string action() const

Returns the form action string (defaults to "form").


partial

const

bool partial() const

Returns true if this is a partial form submission.


setAction

void setAction(std::string_view action)

Sets the form action field. Throws std::invalid_argument for unrecognised values. Possible values: form - Form-processing entity requests form completion. submit - Form-submitting entity is sending data. cancel - Form-submitting entity cancelled submission. result - Form-processing entity is returning data.

Parameters

  • action Action string.

setPartial

void setPartial(bool flag)

Marks the form as a partial section for live/auto-complete updates. Partial forms transmit only the changed fields rather than the entire form payload.

Parameters

  • flag True to mark as partial.