Accessing field rules
nilshoerrmann opened this issue · 2 comments
It would be great if there was a way to access field rules in order to work with them in templates and snippets. E. g. $form->fields()
returning all field rules or $form->fields($name)
only returning the rules for a specific field. This would be helpful to automatically set the required
attribute on an input based on the validation settings without having to pass that array manually through all nested snippets.
Sounds like a useful addition to kirby-form. However, I would not only return the field rules but the whole attributes array of the field (rules, messages, etc.). Care to make a pull request?
Here is a pull request for fields, rules and messages getters with a few open questions:
https://github.com/mzur/kirby-form/pull/4/files