anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

How to highlight custom field when raise error for it? #245

Closed iwill closed 2 years ago

iwill commented 2 years ago

Hi, I have a custom field, and I'd like to validate its value in the Ruby script, but I need some helps:

Thanks in advance!

AirTibu commented 2 years ago

Hi,

The custom_workflow plugin is not able to change the color of field frames, but you can raise an error message, like this:

image

Use this code (change the custom_field ID and the validation):


unless custom_field_value(155) == "This is the right value"

    errors.add(:base,"This is not the right value for #{CustomField.find(155).name.to_s} field!") 

end

I hope it helps!

iwill commented 2 years ago

Yes, CustomField.find(155).name helped me! The following code can highlight the custom field:

errors.add(CustomField.find(155).name, "#{CustomField.find(155).name.to_s} is invalid")

Thank you very much! @AirTibu