Hi,
I'm trying to get my head around the form framework in Symfony 1.4. I've read the incredibly detailed section in the 'More with symfony' book, but I'm still a but unsure how to implement a simple 'Change password' functionality.
The requirements are pretty basic,
- There'll be two fields,
new_password
, andconfirm_new_password
. Both will be input fields. - The
new_password
field will be validated to be a string between 6 and 30 characters containing both letters and numbers. - The
confirm_new_password
field will be validated to match thenew_password
field exactly.
Now, presently I implemented this by,
- Adding 2 new fields to my form.
- Adding a string validator to the
new_password
field to check the string length. - Adding a string validator to the
confirm_new_password
field to make sure it was filled in. - And then validating the new password is valid and matches the confirm password in a custom post validator. I did this because I didn't want to validate the
confirm_new_password
field until thenew_password
field was valid.
Now to the point of my question. After reading the article mentioned above, I'm starting to think I should contain the two fields in either a single widget or in a sub form as they rely upon each other heavily, and one is useless without the other.
I was wondering what peoples thoughts were on this, and if someone had implemented one, how they did it?
Thanks
Note: There is no current_password
field as this is for my admin area.