|
|
constexpr | Choice () noexcept=default |
| | Constructs the empty state.
|
| constexpr | Choice (T selected) noexcept(std::is_nothrow_move_constructible_v< T >) |
| | Engages with selected.
|
| constexpr | Choice (std::optional< T > payload) noexcept(std::is_nothrow_move_constructible_v< T >) |
| | Adopts an optional payload as-is.
|
| constexpr bool | hasValue () const noexcept |
| | Whether a value has been selected.
|
| constexpr const T & | operator* () const noexcept |
| | Unchecked access to the selected value (UB when empty, exactly like std::optional — the unchecked contract is the point).
|
| constexpr bool | operator== (const Choice &other) const noexcept=default |
| | Equality on the payload; empty equals only empty.
|
|
| static constexpr std::string_view | optionsAction () noexcept |
| | Type id of the action that serves the options.
|
| static constexpr std::string_view | valueField () noexcept |
| | Result-row field submitted as the value.
|
| static constexpr std::string_view | labelField () noexcept |
| | Result-row field displayed to the user.
|
| static constexpr std::array< std::string_view, sizeof...(DependsOn)> | optionsDependsOn () noexcept |
| | Wire field names of sibling fields whose current values parameterise the options action (a cascading picklist).
|
template<typename T,
FixedString OptionsAction,
FixedString ValueField = "id",
FixedString LabelField = "name", FixedString... DependsOn>
struct morph::forms::Choice< T, OptionsAction, ValueField, LabelField, DependsOn >
An optionally-empty value selected from options served by another action.
- Template Parameters
-
| T | Underlying value type submitted on the wire (e.g. std::int64_t for ids, std::string for codes). |
| OptionsAction | Type id of the registered action whose result provides the options. Executed with an empty body when DependsOn is empty (the common case); otherwise with a body built from the current values of the named sibling fields. |
| ValueField | Field of each result row submitted as the value. |
| LabelField | Field of each result row shown to the user. |
| DependsOn | Wire (JSON) field names of sibling fields in the same action whose current values parameterise the options action — a cascading picklist. Empty by default, which makes the options action independent (today's behavior, unchanged). |
Definition at line 86 of file choice.hpp.