![]() This sub-module ships more specific validators for “Postal code”, “Color(HTML5)” and much more. I have to mention that there’s a sub-module called “Field validation extras”. But trust me, spend some time playing with it and you’ll be amazed how powerful it is. I’ve only shown you one small bit of what Field validation can really do. Just select your custom validation from the “Field validation” component and add it to your feature. Field validation has complete Features integration. You may be thinking to yourself, this is all good but can I export the configuration into code? Yes you can. Now if you try and create two articles with the same “ID number” value you should see “ID number must be unique.”. Click on “Replacement patterns” to see which ones are available. You can use certain tokens in your messages. You may have noticed that I used “” in the message. Enter in “ must be unique.” into the “Custom error message” field. The final thing we need to do is create a validation message. You can further configure the validator from the field-set, below the drop-down. Click on the Validator drop-down and select “Unique values”. Finally, select value from the Column drop-down.Īt this point, we’re given the validation a name and selected which field we want to validate. If this field was on the user entity then you would select User as the “Entity type” and Bundle.Ĥ. ![]() From “Entity type” select Node, from “Bundle” select Article and from “Field name” select “ID number” (the field we want to validate.)īecause we added the field to the Article content type, we selected Node from the “Entity type” and Article from the Bundle. In the Name field enter in “id_number_validation”, “ID number validation” in the “Rule name” field.ģ. Click on Structure from the toolbar, click on “Field Validation” and “Add”.Ģ. Let’s now configure a validator which will be used to make sure the field value is unique.ġ. I’ve created a field called “ID number” which I’ve attached to the Article content type. ![]() Of course, you could you implement this type of validation with custom code, but Field validation can handle it with just a few easy clicks. The module comes with one useful validator which checks if a field value is unique. If you use Drush, run the following command: drush dl field_validation ctools Before we begin, go download Field validation, Ctools and enable “Field Validation UI”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |