Form
Form
#include <icy/symple/form.h>class FormDefined 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
| Name | Kind | Owner |
|---|---|---|
Form | function | Declared here |
Form | function | Declared here |
Form | function | Declared here |
~Form | function | Declared here |
valid | function | Declared here |
action | function | Declared here |
partial | function | Declared here |
setAction | function | Declared here |
setPartial | function | Declared here |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
operator= | function | Inherited from FormElement |
~FormElement | function | Inherited from FormElement |
type | function | Inherited from FormElement |
id | function | Inherited from FormElement |
label | function | Inherited from FormElement |
setType | function | Inherited from FormElement |
setId | function | Inherited from FormElement |
setLabel | function | Inherited from FormElement |
setHint | function | Inherited from FormElement |
setError | function | Inherited from FormElement |
addPage | function | Inherited from FormElement |
addSection | function | Inherited from FormElement |
addField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
hasField | function | Inherited from FormElement |
setLive | function | Inherited from FormElement |
live | function | Inherited from FormElement |
clearElements | function | Inherited from FormElement |
clear | function | Inherited from FormElement |
valid | function | Inherited from FormElement |
numElements | function | Inherited from FormElement |
hasErrors | function | Inherited from FormElement |
hasPages | function | Inherited from FormElement |
root | function | Inherited from FormElement |
_root | variable | Inherited from FormElement |
Inherited from FormElement
| Kind | Name | Description |
|---|---|---|
function | FormElement | Constructs an unbound element (root pointer is null). |
function | FormElement | Constructs an element bound to the given JSON node. |
function | FormElement | Copy constructor; copies the root pointer reference (shallow). |
function | operator= | Copy-assigns the root pointer reference. |
function | ~FormElement virtual | |
function | type const | Returns the element type string. |
function | id const | Returns the element ID string. |
function | label const | Returns the display label string. |
function | setType | Sets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom |
function | setId | Sets the element ID field. |
function | setLabel | Sets the display label field. |
function | setHint | Sets the hint/description field shown below the element. |
function | setError | Sets an optional validation error message. |
function | addPage | Appends a page child element and returns a handle to it. |
function | addSection | Appends a section child element and returns a handle to it. |
function | addField | Appends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type. |
function | getField | Searches child elements for the field with the given ID. |
function | getField | Populates a FormField by searching child elements for the given ID. |
function | hasField | Returns true if any child element has an ID matching the given value. |
function | setLive | Sets 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. |
function | live const | Returns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes. |
function | clearElements | Removes all child elements whose ID matches the given value. |
function | clear | Clears all fields from the underlying JSON node. |
function | valid const | Returns true if the form element is valid. |
function | numElements | Returns the number of child elements. |
function | hasErrors | Returns true if any fields have errors. |
function | hasPages | Returns true if the form has multiple pages. |
function | root const | Returns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null. |
variable | _root | The root pointer is just a reference to the externally managed JSON value memory. |
Public Methods
| Return | Name | Description |
|---|---|---|
Form | Constructs an unbound form (root pointer is null). | |
Form | Constructs a form bound to the given JSON node. Sets the type field to "form". | |
Form | Constructs a form from a Command, binding to command["form"]. Sets the type field to "form". | |
bool | valid | Returns true if the element is valid, non-empty, and has no errors. |
std::string | action const | Returns the form action string (defaults to "form"). |
bool | partial const | Returns true if this is a partial form submission. |
void | setAction | 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. |
void | setPartial | 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. |
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
rootJSON 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
rootParent 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() constDefined in src/symple/include/icy/symple/form.h:200
Returns the form action string (defaults to "form").
partial
const
bool partial() constDefined 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
actionAction 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
flagTrue to mark as partial.
