Active
Project:
Field Validation
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Apr 2011 at 21:18 UTC
Updated:
4 Mar 2015 at 07:18 UTC
Jump to comment: Most recent
Comments
Comment #1
g089h515r806 commentedNow, field validation rule is cloneable.If you want to reuse it, just clone it at page admin/structure/field_validation.
Comment #2
jordanmagnuson commentedAny plans for 2.x?
Seems silly to define the same rule over and over again, and name it something different every time, rather than just reusing the same validation rule on multiple fields...
Comment #3
jordanmagnuson commentedI see that we can indeed clone field validations in the 2.x branch, but what about simply reusing existing validations? That would seem like a much better solution...
Comment #4
g089h515r806 commentedI have think about this feature when i start build this module.
In webform validation , one validation rule could attach to several webform components. I removed this feature.
(1) field is much complex than webform component, there are more field types, field coudl also be multi values, multi column.
(2) The module will become very complex that i could not control it.
The benifit we could earn from attach one validation rule to one field is:
(1) we could add several rules to one field.
(2) we could one validation rule to all field types, at leat it is much simpler to do this.
I also want to build a UI like Views UI.
Comment #5
rooby commentedIt is kind of annoying you can't reuse rules and you can't reuse rule names when you do duplicate a rule.
Would it be feasible to have an "Add existing rule" dropdown, like drupal core provides the "Add existing field" one?
It would be on the admin/structure/types/manage/article/fields/body/validation page (and other equivalent pages).
There would just have to be a message to tell people that the settings are global settings and they will affect all fields that this validator is used on.
I don't see why this can't still be the case.
I'm not sure I understand this one.
Comment #6
g089h515r806 commentedIt is possible. But it needs a lot works to do it.
I prefer following structure in the future:
Then we do not need to enter a validation rule name. validation rules export/import base on bundle/entity name.
Comment #7
hnln commentedFYI, it is also possible to create your own validation plugin and use that for all the fields.
Comment #8
raulmuroc commentedSome steps on this? Oh As far as I understand, there are no plans to make it as you prefer to have a Field Validation perspective instead of Validation'sp erspective for fields. So each field has its own validation so no validation for many fields.
I'm not sure is the best... makes the module quite annoying to use and maintain. Imagine I appy 500 times the "numerical value" validation, with a custom message and I want everywhere the same message... must write 500 this message for each validation.
Really not maintainable/scalable.
Comment #9
hnln commentedThat was my problem exactly. I created a custom validation plugin, you can do that by copying any of the module's validators and place it in your own module's plugins/validator directory (like any ctools plugin). You can probably extend on the existing numeric value validator and implement your own 'get_error_message' method. The only downside is that I had to alter the ctools_export_ui_edit_item form to remove the standard 'error_message' (as it's required). This might be something for the maintainers, to make it possible to let the validator decide if a custom error message is required.
The code I needed (beware that the naming of the class is important, otherwise it will complain that it doesn't extend field_validation_validator).
and