没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > custom-field-error |
custom-field-error
|
0 | 0 | 10 |
贡献者 | 讨论 | 代码提交 |
custom_field_error allows you to easily setup custom HTML to be displayed when there is a validation issue with a form. You can setup a different view for every model, or setup a view in one model and have that view be used as the default for all the other models. You can also explicitly override the default view you have chosen by defining another view within another model. Last but not least, you can choose to leave the Rails default view for whatever models you want.
It sounds like a lot, but it's actually very simple. Just put the following line in your model, in this case a User model:
custom_field_error "?
Unknown end tag for
"
Now, if there was an error on a field called "name" in a form, it would look like:
However, this custom view would only be for the User view. To make this view the default view, simply set the second argument to 'default':
custom_field_error "?
Unknown end tag for
", 'default'
However, what if I now want to set a special view for my Project model? Simple. Just set custom_field_error like usual and it'll override the default view:
custom_field_error "?"
Voila! The plugin will automatically figure out what view it needs to display and display it.
Enjoy. If you have any questions, feel free to email me.
NOTE: Google Code doesn't like square brackets, but they're there!