Skip to content

Commit

Permalink
Better implementation of #6016 passing value to callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Mar 19, 2018
1 parent 9eb4ac3 commit e137ee1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion RELEASE-NOTES.md
Expand Up @@ -10,7 +10,7 @@

**Enhancements**
- **Search** - Adds disabled variation **Thanks @prudho** #6225
- **Form Validation** - Form prompt can now be returned by a function **Thanks @xDaizu** #6016 #3864
- **Form Validation** - Form can now return their validation prompt dynamically based on their current value. **Thanks @xDaizu** #6016 #3864

**Bugs**
- **Dropdown** - Fixed `onChange` missing `text` from callback when dropdown is set to `action: 'select'` #4183 #4510
Expand Down
8 changes: 3 additions & 5 deletions src/definitions/behaviors/form.js
Expand Up @@ -435,18 +435,16 @@ $.fn.form = function(parameters) {
var
ruleName = module.get.ruleName(rule),
ancillary = module.get.ancillaryValue(rule),
$field = module.get.field(field.identifier),
value = $field.val(),
prompt = $.isFunction(rule.prompt)
? rule.prompt()
? rule.prompt(value)
: rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
requiresValue = (prompt.search('{value}') !== -1),
requiresName = (prompt.search('{name}') !== -1),
$label,
$field,
name
;
if(requiresName || requiresValue) {
$field = module.get.field(field.identifier);
}
if(requiresValue) {
prompt = prompt.replace('{value}', $field.val());
}
Expand Down

0 comments on commit e137ee1

Please sign in to comment.