Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added value objects for possible values #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ The media type for JSON Siren is `application/vnd.siren+json`.
"fields": [
{ "name": "orderNumber", "type": "hidden", "value": "42" },
{ "name": "productCode", "type": "text" },
{ "name": "quantity", "type": "number" }
{ "name": "quantity", "type": "number" },
{ "name": "color", "type": "radio", "title": "Choose a Color",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A name describing the control. Field names MUST be unique within the set of fields for an action. The behaviour of clients when parsing a Siren document that violates this constraint is undefined. Required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this. The 'color' attribute was not meant to appear twice. Changed to 'accessories'.

"value": [
{ "title": "The Color Red", "value": "red" },
{ "title": "The Color Green", "value": "green", "selected": true }
]
},
{ "name": "accessories", "type": "checkbox", "title": "Choose Accessories",
"value": [
{ "title": "Bells included", "value": "bells", "selected": true },
{ "title": "Whistles included", "value": "whistles", "selected": true }
]
}
]
}
],
Expand Down Expand Up @@ -210,7 +222,7 @@ Fields represent controls inside of actions. They may contain these attributes:

A name describing the control. Field names MUST be unique within the set of fields for an action. The behaviour of clients when parsing a Siren document that violates this constraint is undefined. Required.

###`class`
####class

Describes aspects of the field based on the current representation. Possible values are implementation-dependent and should be documented. MUST be an array of strings. Optional.

Expand All @@ -225,13 +237,29 @@ The input type of the field. This may include any of the following [input types]

When missing, the default value is `text`. Serialization of these fields will depend on the value of the action's `type` attribute. See [`type`](#type) under Actions, above. Optional.

####title

Textual annotation of a field. Clients may use this as a label. Optional.

####value

A value assigned to the field. Optional.
A value assigned to the field. May be a scalar value or a list of value objects. Optional.

####title
#####Value Objects

Textual annotation of a field. Clients may use this as a label. Optional.
Value objects represent multiple selectable field values. Use in conjunction with field `"type" = "radio"` and `"type" = "checkbox"` to express that zero, one or many out of several possible values may be sent back to the server. Value objects may contain these attributes:

######title

Textual description of a field value. Optional.

######value

Possible value for the field. Required.

######selected

A value object with a `"selected" = true` attribute indicates that this value should be considered preselected by the client. When missing, the default value is `false`. Optional.

##Usage Considerations

Expand Down