#include <icy/symple/form.h>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.
| 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()Constructs an unbound field (root pointer is null).
FormField(json::Value & root, std::string_view type, std::string_view id, std::string_view label)Constructs a field bound to the given JSON node.
root JSON node to bind to.
type Field type string (e.g. "text", "list").
id Optional field ID.
label Optional display label.
void addOption(std::string_view key, std::string_view value)Adds a labelled option for list-based fields.
key Option key sent on submit.
value Display label for the option.
void addOption(std::string_view value)Adds an option whose key and display value are identical.
value Option string.void setValue(std::string_view value)Replaces all current values with a single string value.
value String value to set.void setValue(int value)Replaces all current values with a single integer value.
value Integer value to set.void setValue(double value)Replaces all current values with a single double value.
value Double value to set.void setValue(bool value)Replaces all current values with a single boolean value.
value Boolean value to set.void addValue(std::string_view value)Appends a string value to the values array.
value String value to append.void addValue(int value)Appends an integer value to the values array.
value Integer value to append.void addValue(double value)Appends a double value to the values array.
value Double value to append.void addValue(bool value)Appends a boolean value to the values array.
value Boolean value to append.json::Value & values()Returns a reference to the JSON array of all values.
const
std::string value() constReturns the first value as a string. Most field types (except multi-value) only use a single value.
const
int intValue() constReturns the first value parsed as an integer.
const
double doubleValue() constReturns the first value parsed as a double.
const
bool boolValue() constReturns the first value parsed as a boolean. Treats "1", "true", and "on" as true; all other strings as false.