I'm trying to validate a form made from an ORM object. However, I want some fields to be disabled, but they happen to have a "required" rule, and doc indicates that this doesn't disable validation.
Why is that? If the user cannot interact with the field in the first place, it will of course never be validated. I would like to remove the validation rule on this field, but even the function "$field->delete_rule" doesn't work, as it seems the ruleset hasn't been created even if I make the call juste before "$validation->run()".
Disabling a field from a fieldset was designed so you could generate the fieldset in the view in different sections. Say you have fields A,B,C,D, you could disable C and D, create an HTML fieldset and build the field (which would output A and B, then enable them and disable C and D, create a second HTML fieldset and build the fieldset again.
It was not designed to remove fields from the fieldset, for that you would need a delete() method (as opposite to the add() method), but that has never been implemented with the idea that if you don't need a field, you should not have added it in the first place.
Nevermind, I was doing "delete_rule" on the wrong field all along. It would be nice, however, if this function was documented (in fact, if the whole Field class was).
Also, I understand the rationale for disabling/re-enabling fields from fieldsets, I just think that having the option to disable/re-enable the validation with it would be useful and make the whole thing more intuitive.
As for removing fields from fieldsets, I think the option should be there, in the same way we can disable / re-enable fields, especially since some sets are generated automatically (from ORM). In my opinion, more flexibility tend to be a plus in cases like these, rather than trying to impose a specific coding philosophy. I think I might be interested in implementing these functions eventually, even if just as a core extension.
The entire fieldset system as it exists today is very inflexible to begin with, which is why all these add, delete, enable and disable methods exist. There was even discussion about move methods (to re-arrange fields) in the past!
We dislike it so much, that it is being completely rewritten for Fuel v2. If you have thought about how it should behave or what it should be able to do, go to https://github.com/fuelphp/fieldset/issues or check out the wiki for some examples.
As for the docs, the fact that parts of it as missing can probably be contributed to the fact that the person responsible for coding didn't document it, and is no longer with the team. Any until now, nobody has found the will to dive into the code and document the rest.
If you feel up to the task, fork the fuel/docs repository, make your changes, send in a PR, and make history!
Actually, I might just do that if I manage to get some free time. Even if there are a few problems here and there, this is actually one of the best frameworks I've tried and it has saved me a whole lot of time and trouble so far.
I'll check if I can contribute something to the future versions.