Class jabberwerx.XDataForm
Extends
JWModel.
Holds data form fields and properties.
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.XDataForm(form, payload)
Creates a new XDataForm with the given DOM element or empty form of the given type. |
Field Attributes | Field Name and Description |
---|---|
Array of XDataFormFields objects for the forms of type "form" and "submit"
|
|
Array of XDataFormFields objects for the forms of type "result"
|
|
Array of XDataFormFields objects for the forms of type "result"
|
Method Attributes | Method Name and Description |
---|---|
addField(field)
Adds field to the data form. |
|
cancel()
Returns XDataForm type "cancel". |
|
destroy()
Destroys this data form. |
|
getDOM()
Returns XDataForm DOM element. |
|
getFieldByVar(name)
Returns field based on var name or null if not found or name is null. |
|
getFieldValue(name)
Returns first value for the field based on var name or null if field is not found or no values exist for the field. |
|
Returns field based on var name or null if not found or name is null. |
|
Returns form instructions. |
|
getTitle()
Returns form title. |
|
getType()
Returns form type. |
|
setFieldValue(name, value, type)
Sets/clears value for the field based on var name. |
|
setFORM_TYPE(type)
Sets form type field value for the form. |
|
setInstructions(instructions)
Sets form instructions. |
|
setTitle(title)
Sets form title. |
|
submit(fieldsAndValues)
Creates new jabberwerx.XDataForm and sets values for the passed var(s). |
|
validate()
Iterates through all the form fields and performs the validation. |
Creates a new XDataForm with the given DOM element or empty form of the given type.
- Parameters:
- {String} form Optional
- The form type
- {Element} payload Optional
- The DOM representing XDataForm
- Throws:
- {TypeError}
- If any of the parameters are not valid
Adds field to the data form.
- Parameters:
- {jabberwerx.XDataFormField} field Optional
- Field to add to the form
Returns XDataForm type "cancel".
- Returns:
- {jabberwerx.XDataForm} Newly created form of type "cancel".
Destroys this data form.
Returns XDataForm DOM element.
- Returns:
- {Element} DOM element representing XDataForm
Returns field based on var name or null if not found or name is null.
- Parameters:
- {String} name Optional
- Var value for the field
- Returns:
- {jabberwerx.XDataFormField}
Returns first value for the field based on var name or null if field is not found or no values exist for the field.
- Parameters:
- {String} name Optional
- Var value for the field
- Returns:
- {String} First value for the field
Returns field based on var name or null if not found or name is null.
- Returns:
- {String} 'FORM_TYPE' value for the form
Returns form instructions.
- Returns:
- {String} Form instructions
Returns form title.
- Returns:
- {String} Form title
Returns form type.
- Returns:
- {String} Form type
Sets/clears value for the field based on var name.
This method uses the following algorithm:
- If there is no existing field for {name}, a new one is created and inserted into the end of this form, with a type of {type} (or "text-single" if not provided).
- If there is an existing field for {name}, and {value} is not null or undefined, its value is updated to {value}, and {type} is ignored.
- If there is an existing field for {name}, and {value} is null or undefined, the field is removed.
- Parameters:
- {String} name Optional
- Var name for the field
- {String} value Optional
- Value for the field
- {String} type Optional
- Type for the field
Sets form type field value for the form.
- Parameters:
- {String} type Optional
- 'FORM_TYPE' value for the form
Sets form instructions.
- Parameters:
- {String} instructions Optional
- Form instructions
Sets form title.
- Parameters:
- {String} title Optional
- Form title
Creates new jabberwerx.XDataForm and sets values for the passed var(s).
- Parameters:
- {Object} fieldsAndValues Optional
- Object containing id/value pairs for data fields.
- Returns:
- {jabberwerx.XDataForm} Newly created form of type "submit".
Iterates through all the form fields and performs the validation.
- Throws:
- {TypeError}
- If any of the rules for field's values have been violated