Skip to content

Commit

Permalink
Hint
Browse files Browse the repository at this point in the history
Hint can be function.
  • Loading branch information
hansi90 committed Oct 4, 2017
1 parent 5099907 commit 4fe380e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 57 deletions.
116 changes: 60 additions & 56 deletions dev/full/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
required: true,
hint: "Minimum 6 characters",
styleClasses: "half-width",
validator: validators.string.locale({
validator: validators.string.locale({
fieldIsRequired: "The password is required!",
textTooSmall: "Password must be at least {1} characters!"
})
Expand Down Expand Up @@ -210,60 +210,60 @@ module.exports = {
model: "",
styleClasses: "alert alert-info"
}, {
type: "checklist",
label: "CHECKLIST combobox",
model: "checklistcombobox",
listBox: false,
values: [{
name: "HTML5",
value: "HTML5-123"
}, {
name: "Javascript",
value: "Javascript-123"
}, {
name: "CSS3",
value: "CSS3-123"
}, {
name: "CoffeeScript",
value: "CoffeeScript-123"
}, {
name: "AngularJS",
value: "AngularJS-123"
}, {
name: "ReactJS",
value: "ReactJS-123"
}, {
name: "VueJS",
value: "VueJS-123"
}],
}, {
type: "checklist",
label: "CHECKLIST listBox",
model: "checklistlistbox",
listBox: true,
values: [{
name: "HTML5",
value: "HTML5-123"
}, {
name: "Javascript",
value: "Javascript-123"
}, {
name: "CSS3",
value: "CSS3-123"
}, {
name: "CoffeeScript",
value: "CoffeeScript-123"
}, {
name: "AngularJS",
value: "AngularJS-123"
}, {
name: "ReactJS",
value: "ReactJS-123"
}, {
name: "VueJS",
value: "VueJS-123"
}],
}, {
type: "checklist",
label: "CHECKLIST combobox",
model: "checklistcombobox",
listBox: false,
values: [{
name: "HTML5",
value: "HTML5-123"
}, {
name: "Javascript",
value: "Javascript-123"
}, {
name: "CSS3",
value: "CSS3-123"
}, {
name: "CoffeeScript",
value: "CoffeeScript-123"
}, {
name: "AngularJS",
value: "AngularJS-123"
}, {
name: "ReactJS",
value: "ReactJS-123"
}, {
name: "VueJS",
value: "VueJS-123"
}],
}, {
type: "checklist",
label: "CHECKLIST listBox",
model: "checklistlistbox",
listBox: true,
values: [{
name: "HTML5",
value: "HTML5-123"
}, {
name: "Javascript",
value: "Javascript-123"
}, {
name: "CSS3",
value: "CSS3-123"
}, {
name: "CoffeeScript",
value: "CoffeeScript-123"
}, {
name: "AngularJS",
value: "AngularJS-123"
}, {
name: "ReactJS",
value: "ReactJS-123"
}, {
name: "VueJS",
value: "VueJS-123"
}],
}, {
type: "radios",
label: "RADIOS",
model: "radios",
Expand Down Expand Up @@ -319,7 +319,11 @@ module.exports = {
type: "textArea",
label: "Biography (textArea field)",
model: "bio",
hint: "Max 500 characters",
hint: function (model) {
if (model && model.bio) {
return model.bio.length + " of max 500 characters used!";
}
},
max: 500,
placeholder: "User's biography",
rows: 4,
Expand Down
10 changes: 9 additions & 1 deletion src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ div.vue-form-generator(v-if='schema != null')
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :formOptions='options', @model-updated='modelUpdated', @validated="onFieldValidated")
.buttons(v-if='buttonVisibility(field)')
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field, $event)', :class='btn.classes') {{ btn.label }}
.hint(v-if='field.hint') {{ field.hint }}
.hint(v-if='field.hint') {{ fieldHint(field) }}
.errors.help-block(v-if='fieldErrors(field).length > 0')
span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }}

Expand Down Expand Up @@ -274,6 +274,14 @@ div.vue-form-generator(v-if='schema != null')
return field.featured;
},
// Get current hint.
fieldHint(field){
if (isFunction(field.hint))
return field.hint.call(this, this.model, field, this);
return field.hint
},
buttonClickHandler(btn, field, event) {
return btn.onclick.call(this, this.model, field, event, this);
Expand Down

0 comments on commit 4fe380e

Please sign in to comment.