Select (Planned)
📖 Table of Contents
Status
Planned, not implemented: SmarkForm currently treats
<select>as an ordinaryinputfield. It does not process asrcoption, fetch option data, or update options when another field changes. See the Roadmap.
Proposal sketch only (not runnable):
<select data-smark='{
"src":[
"https://example.com/some/api",
{
"someConstant":"actual_value",
"@someField":"sibling_field_name",
"@someOtherField":"/absolute/path/to/field",
"@anotherField":"../relative/path/to/field"
},
"GET"
]
}'>
</select>
Where:
- src[0]: Provides the endpoint url.
- If it is the only argument provided, src can be simplified as just that url.
- src[1]: (Optional) Provides arguments to be passed.
- src[2]: (Optional) Specifies the HTTP method (‘GET’ by default).
Proposed API Interface behavior (not implemented):
If implemented, the API Interface proposal would fetch data based on the specified endpoint, arguments, and other parameters (such as the method), while also keeping track of changes in every field it depends on (those marked with an initial @) so the consuming component (a select here) could update its options when relevant data changes.
One proposed feature is an interchangeable callback, called an adapter, for performing the fetch.
The default adapter described in the proposal would execute an HTTP request.
An application could replace it with an implementation for another API style or a mock used in tests.