Home
Symple module

Form

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

Form

#include <icy/symple/form.h>
class Form

Defined in src/symple/include/icy/symple/form.h:178

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.

List of all members

NameKindOwner
FormfunctionDeclared here
FormfunctionDeclared here
FormfunctionDeclared here
~FormfunctionDeclared here
validfunctionDeclared here
actionfunctionDeclared here
partialfunctionDeclared here
setActionfunctionDeclared here
setPartialfunctionDeclared here
FormElementfunctionInherited from FormElement
FormElementfunctionInherited from FormElement
FormElementfunctionInherited from FormElement
operator=functionInherited from FormElement
~FormElementfunctionInherited from FormElement
typefunctionInherited from FormElement
idfunctionInherited from FormElement
labelfunctionInherited from FormElement
setTypefunctionInherited from FormElement
setIdfunctionInherited from FormElement
setLabelfunctionInherited from FormElement
setHintfunctionInherited from FormElement
setErrorfunctionInherited from FormElement
addPagefunctionInherited from FormElement
addSectionfunctionInherited from FormElement
addFieldfunctionInherited from FormElement
getFieldfunctionInherited from FormElement
getFieldfunctionInherited from FormElement
hasFieldfunctionInherited from FormElement
setLivefunctionInherited from FormElement
livefunctionInherited from FormElement
clearElementsfunctionInherited from FormElement
clearfunctionInherited from FormElement
validfunctionInherited from FormElement
numElementsfunctionInherited from FormElement
hasErrorsfunctionInherited from FormElement
hasPagesfunctionInherited from FormElement
rootfunctionInherited from FormElement
_rootvariableInherited from FormElement

Inherited from FormElement

KindNameDescription
functionFormElementConstructs an unbound element (root pointer is null).
functionFormElementConstructs an element bound to the given JSON node.
functionFormElementCopy constructor; copies the root pointer reference (shallow).
functionoperator=Copy-assigns the root pointer reference.
function~FormElement virtual
functiontype constReturns the element type string.
functionid constReturns the element ID string.
functionlabel constReturns the display label string.
functionsetTypeSets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom
functionsetIdSets the element ID field.
functionsetLabelSets the display label field.
functionsetHintSets the hint/description field shown below the element.
functionsetErrorSets an optional validation error message.
functionaddPageAppends a page child element and returns a handle to it.
functionaddSectionAppends a section child element and returns a handle to it.
functionaddFieldAppends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type.
functiongetFieldSearches child elements for the field with the given ID.
functiongetFieldPopulates a FormField by searching child elements for the given ID.
functionhasFieldReturns true if any child element has an ID matching the given value.
functionsetLiveSets the live flag on this element. Live elements are used to submit partial form sections (e.g. for auto-complete) without sending the entire form.
functionlive constReturns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes.
functionclearElementsRemoves all child elements whose ID matches the given value.
functionclearClears all fields from the underlying JSON node.
functionvalid constReturns true if the form element is valid.
functionnumElementsReturns the number of child elements.
functionhasErrorsReturns true if any fields have errors.
functionhasPagesReturns true if the form has multiple pages.
functionroot constReturns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null.
variable_rootThe root pointer is just a reference to the externally managed JSON value memory.

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()

Defined in src/symple/include/icy/symple/form.h:182

Constructs an unbound form (root pointer is null).


Form

Form(json::Value & root)

Defined in src/symple/include/icy/symple/form.h:187

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)

Defined in src/symple/include/icy/symple/form.h:192

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

Parameters

  • root Parent command message.

valid

bool valid()

Defined in src/symple/include/icy/symple/form.h:197

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


action

const

std::string action() const

Defined in src/symple/include/icy/symple/form.h:200

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


partial

const

bool partial() const

Defined in src/symple/include/icy/symple/form.h:203

Returns true if this is a partial form submission.


setAction

void setAction(std::string_view action)

Defined in src/symple/include/icy/symple/form.h:213

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)

Defined in src/symple/include/icy/symple/form.h:219

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.