Form¶
-
/libs/granite/ui/components/coral/foundation/form Form is a component to represent a standard HTML form (<form>).
It has the following content structure:
-
granite:Form
- granite:commonAttrs
- granite:renderCondition
- granite:container
- actionstringel
The
actionattribute.The value MUST be resolved into a relative URL starting with the path, query, or fragment component. e.g.
http://example.org/is not valid, while/abc.htmlandabc.htmlare.
- enctypestring
The
enctypeattribute.
-
methodstring
- get
- post
The
methodattribute.
- targetstring
The
targetattribute.
- autocompletestring
Indicates if input elements can by default have their values automatically completed by the browser.
See also MDN documentation regarding autocomplete attribute.
- novalidateboolean
The
novalidateattribute to indicate that the form is not to be validated when submitted.
- dataPathstringel
The path to the resource to be used as the values by the contained form fields.
The ValueMap of the resource is used as the FormData that is matched by
nameproperty of the field.Given the following structure:
+ /apps/example/myformvalues - name1 = "value1" - name2 = ["value1", "value2"] + /apps/example/myform - sling:resourceType = "granite/ui/components/coral/foundation/form" - dataPath = "/apps/example/myformvalues" + items + textfield - sling:resourceType = "granite/ui/components/coral/foundation/form/textfield" - name = "name1"
The textfield will be matched with
name1key. The textfield will then usevalue1as its value.The value of the field
namecan be any string that can be passed to ValueMap#get(). So relative value works. e.g.name1,./name1,./childNode1/prop1.The form is often used in conjunction with SlingPostServlet as the submission endpoint, where it defines a certain field name convention.
-
nameNotFoundModestring
- ignore-freshness
- check-freshness
- ignore-freshness
The mode on how to handle the scenario when the FormData doesn’t have an entry of a certain name.
-
stylestring
- vertical
- aligned
The layout style of the form.
- (no value)
- No style is applied.
- vertical
- The form fields (and their labels) are laid out in vertical manner.
- aligned
- The each form field is laid out side-by-side with its label.
- autosubmitFormboolean
trueto make the form (assigned to this layout) submitable when pressing “Enter”. It is implemented by generating the submit button automatically, and leverage the native browser behavior.
- marginboolean
Put vertical margin to the root element.
- maximizedboolean
Make the element maximized to fill the available space.
- foundationFormboolean
Enable the
foundation-form. This will addfoundation-formclass to the form.
-
asyncboolean
- true
trueif the form is to be submitted using ajax asynchronously, instead of standard synchronous behavior.Only applicable when
foundationFormistrue.
-
loadingMaskboolean
- true
trueto show a mask during form submission. Otherwise no mask is shown at all.Only applicable when
foundationFormistrue.
- uistring
noneto suppress certain UI behavior; otherwise an error UI is shown during error response.Only applicable when
foundationFormistrue.
- successresponse
The config of success response behaviour. See build-in responses.
Only applicable when
foundationFormistrue.
-
granite:Form
Components: