FormField
FormField
#include <icy/symple/form.h>class FormFieldDefined in src/symple/include/icy/symple/form.h:227
Inherits:
FormElement
Form input field with typed values and selectable options.
Values are stored as strings in a JSON array. Typed accessors (intValue, doubleValue, boolValue) parse the first string on demand.
List of all members
| Name | Kind | Owner |
|---|---|---|
FormField | function | Declared here |
FormField | function | Declared here |
~FormField | function | Declared here |
addOption | function | Declared here |
addOption | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
values | function | Declared here |
value | function | Declared here |
intValue | function | Declared here |
doubleValue | function | Declared here |
boolValue | 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 |
|---|---|---|
FormField | Constructs an unbound field (root pointer is null). | |
FormField | Constructs a field bound to the given JSON node. | |
void | addOption | Adds a labelled option for list-based fields. |
void | addOption | Adds an option whose key and display value are identical. |
void | setValue | Replaces all current values with a single string value. |
void | setValue | Replaces all current values with a single integer value. |
void | setValue | Replaces all current values with a single double value. |
void | setValue | Replaces all current values with a single boolean value. |
void | addValue | Appends a string value to the values array. |
void | addValue | Appends an integer value to the values array. |
void | addValue | Appends a double value to the values array. |
void | addValue | Appends a boolean value to the values array. |
json::Value & | values | Returns a reference to the JSON array of all values. |
std::string | value const | Returns the first value as a string. Most field types (except multi-value) only use a single value. |
int | intValue const | Returns the first value parsed as an integer. |
double | doubleValue const | Returns the first value parsed as a double. |
bool | boolValue const | Returns the first value parsed as a boolean. Treats "1", "true", and "on" as true; all other strings as false. |
FormField
FormField()Defined in src/symple/include/icy/symple/form.h:231
Constructs an unbound field (root pointer is null).
FormField
FormField(json::Value & root, std::string_view type = "", std::string_view id = "", std::string_view label = "")Defined in src/symple/include/icy/symple/form.h:238
Constructs a field bound to the given JSON node.
Parameters
rootJSON node to bind to.typeField type string (e.g. "text", "list").idOptional field ID.labelOptional display label.
addOption
void addOption(std::string_view key, std::string_view value)Defined in src/symple/include/icy/symple/form.h:245
Adds a labelled option for list-based fields.
Parameters
keyOption key sent on submit.valueDisplay label for the option.
addOption
void addOption(std::string_view value)Defined in src/symple/include/icy/symple/form.h:249
Adds an option whose key and display value are identical.
Parameters
valueOption string.
setValue
void setValue(std::string_view value)Defined in src/symple/include/icy/symple/form.h:253
Replaces all current values with a single string value.
Parameters
valueString value to set.
setValue
void setValue(int value)Defined in src/symple/include/icy/symple/form.h:257
Replaces all current values with a single integer value.
Parameters
valueInteger value to set.
setValue
void setValue(double value)Defined in src/symple/include/icy/symple/form.h:261
Replaces all current values with a single double value.
Parameters
valueDouble value to set.
setValue
void setValue(bool value)Defined in src/symple/include/icy/symple/form.h:265
Replaces all current values with a single boolean value.
Parameters
valueBoolean value to set.
addValue
void addValue(std::string_view value)Defined in src/symple/include/icy/symple/form.h:269
Appends a string value to the values array.
Parameters
valueString value to append.
addValue
void addValue(int value)Defined in src/symple/include/icy/symple/form.h:273
Appends an integer value to the values array.
Parameters
valueInteger value to append.
addValue
void addValue(double value)Defined in src/symple/include/icy/symple/form.h:277
Appends a double value to the values array.
Parameters
valueDouble value to append.
addValue
void addValue(bool value)Defined in src/symple/include/icy/symple/form.h:281
Appends a boolean value to the values array.
Parameters
valueBoolean value to append.
values
json::Value & values()Defined in src/symple/include/icy/symple/form.h:284
Returns a reference to the JSON array of all values.
value
const
std::string value() constDefined in src/symple/include/icy/symple/form.h:288
Returns the first value as a string. Most field types (except multi-value) only use a single value.
intValue
const
int intValue() constDefined in src/symple/include/icy/symple/form.h:291
Returns the first value parsed as an integer.
doubleValue
const
double doubleValue() constDefined in src/symple/include/icy/symple/form.h:294
Returns the first value parsed as a double.
boolValue
const
bool boolValue() constDefined in src/symple/include/icy/symple/form.h:298
Returns the first value parsed as a boolean. Treats "1", "true", and "on" as true; all other strings as false.
