|
| 1 | +# Available fields |
| 2 | + |
| 3 | +## Built-in fields |
| 4 | + |
| 5 | +For this fields there is no need 3rd party libraries |
| 6 | + |
| 7 | +- [`text`](text.md) - Simple text input field |
| 8 | +- `email` - E-mail address input field |
| 9 | +- `password` - Password input field |
| 10 | +- `number` - Number input field |
| 11 | +- `textArea` - Text area field |
| 12 | +- `checkbox` - Checkbox for boolean values |
| 13 | +- `select` - Select list |
| 14 | +- `color` - Color picker (built-in HTML5 control) |
| 15 | +- `checklist` - Checkbox list to select multiple values |
| 16 | +- `range` - Range slider (built-in HTML5 control) |
| 17 | +- `image` - Image select field (URL or upload in base64 string) |
| 18 | +- `label` - Static text (e.g. timestamp, creation time...etc) |
| 19 | + |
| 20 | +## Optional fields |
| 21 | + |
| 22 | +For this fields needs 3rd party libraries |
| 23 | + |
| 24 | +- `selectEx` - select list with the bootstrap-select component |
| 25 | +- `dateTime` - datetime picker with bootstrap-datetimepicker component |
| 26 | +- `masked` - Masked text input field with maskedinput component |
| 27 | +- `slider` - pretty range slider with ion.rangeSlider component |
| 28 | +- `spectrum` - Color picker with "The No Hassle" Spectrum jQuery Colorpicker component |
| 29 | + |
| 30 | +## Common properties of field |
| 31 | + |
| 32 | +Property | Type | Description |
| 33 | +--------------- | ------------- | ----------- |
| 34 | +type | `String` | Type of field |
| 35 | +label | `String` | Label of field |
| 36 | +model | `String` | Name of property in the model |
| 37 | +featured | `boolean` | is it a featured (bold) field? |
| 38 | +disabled | `boolean` | if true, disable this field |
| 39 | +required | `boolean` | if true, must be fill this field |
| 40 | +default | any | Default value of the field (for create a new model) |
| 41 | +validator | `Function` or `Array` | Validator for value. It can be array of functions too. |
| 42 | +onChanged | `Function` | Event if this field value is changed. `onChanged(model, newVal, oldVal, field) { ... }` |
| 43 | +onValidated | `Function` | Event if validation executed. `onValidated(model, errors, field) { ... }` |
| 44 | + |
| 45 | +## Example |
| 46 | + |
| 47 | +```js |
| 48 | + { |
| 49 | + type: "text", |
| 50 | + label: "Name", |
| 51 | + model: "name", |
| 52 | + readonly: false, |
| 53 | + featured: true, |
| 54 | + disabled: false, |
| 55 | + required: true, |
| 56 | + default: "Anonymous", |
| 57 | + validator: validators.string, |
| 58 | + |
| 59 | + onChanged(model, newVal, oldVal, field) { |
| 60 | + console.log(`Model's name changed from ${oldVal} to ${newVal}. Model:`, model); |
| 61 | + }, |
| 62 | + |
| 63 | + onValidated(model, errors, field) { |
| 64 | + if (errors.length > 0) |
| 65 | + console.warn("Validation error in Name field! Errors:", errors); |
| 66 | + } |
| 67 | + } |
| 68 | +``` |
0 commit comments