Browse Source

Merge pull request #59 from narutosanjiv/master

added the example in documentation for rails field convention
Phuoc Nguyen 12 years ago
parent
commit
c025cbea8f
1 changed files with 16 additions and 0 deletions
  1. 16 0
      README.md

+ 16 - 0
README.md

@@ -250,6 +250,22 @@ $(form).bootstrapValidator({
 });
 ```
 
+For Rails, the input field is constructed from model name and field name. For Example, User have email as field, when form helper render
+view, the input field name will be 'user[email]'. The syntax for these is somewhat different as shown below:
+```javascript
+$(form).bootstrapValidator({
+    fields: {
+        'user[email]': {
+            // Replace <validatorName> with the name of validator
+            // <validatorOptions> will be passed as third parameter of the
+            // validate(validator, $field, options) method
+            <validatorName>: <validatorOptions>
+        }
+    }
+});
+```
+
+
 To see how built-in validators are developed, you can look at their sources located at the [```src/js/validator```](src/js/validator) directory.
 
 ## Build