-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form/Fieldset messy and not interchangeable #6
Comments
Please look at the top of the page, this documentation is outdated!
Question to you: Why are you doing this? Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
I have already looked at the new docs too but there isn't so much that has changed.
Cause we extended the Form class for faster development and code reduction (i.e. calling a single line for adding a commmon element instead of passing a huge array or creating objects). And I don't understand why Form vs Fieldset hydration/binding differ so much from each other. One of the main bind errors I just solved by adding 1 line to the end of
The docs aren't quite obvious about this topic either, I couldn't find any page that said: "do not nest forms inside forms!" or "here are the distinct differences between form and fieldset" Originally posted by @scroach at zendframework/zend-form#192 (comment) |
Please don't mix the problems here! (Your first statement has nothing to do with the second.) Using forms inside other forms is not a documented way and also not recommended.
Setting a new factory to create the elements was not an option? Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
The first is just the explanation of why we do it this way, the 2nd causes the problems with nesting (which we never needed until now)
I found that out the hard way, but in my opinion this should be handled differently cause debugging why the values have not been bound took me a few hours. For me there are currently 2 options:
I haven't looked into that, maybe our structure isn't the best either but 1) we've got lots and lots of code which works perfectly and 2) thats a whole other topic anyway. Originally posted by @scroach at zendframework/zend-form#192 (comment) |
Replace the factory with your own and you can use this: (pseudo code) Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
Alright, thanks for your input so far. If you say nesting forms isn't supported and never will be I'm gonna have to to fix this for our project or switch to using fieldsets instead. Originally posted by @scroach at zendframework/zend-form#192 (comment) |
HTML doesn't allow nested forms, why should zend-form do something different?
https://www.w3.org/TR/html52/sec-forms.html#the-form-element And zend-form already includes many options to build a form and allowing nested forms means further complications; for code and documentation. Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
What we can do here: throw an exception if a form is add to a form. Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
If you consider the HTML side - yeah you're right. Originally posted by @scroach at zendframework/zend-form#192 (comment) |
I never said that I like this implementation. 😉 For me the main reason is the explanation for the end user. This component is quite heavy and has many many options. Therefore nested forms are the wrong direction. Also the comparison to HTML forms is for users quite simple. Originally posted by @froschdesign at zendframework/zend-form#192 (comment) |
Since I did not get any response in the slack channel and couldn't find anything related:
Currently Zend Form and Fieldset seem like a huge mess to me.
In most of our projects we extendes the Form class to make our form generation easier and faster. And since Form extends Fieldset I thought they were kinda exchangeable in terms of nested forms/fieldsets - but as it seems they are not.
Now I tried to compose multiple Forms into a bigger one with collections trying to carve the code out of this doc: https://framework.zend.com/manual/2.4/en/modules/zend.form.collections.html
This didn't work (due to several reasons?). The collection has never been hydrated. After lots and lots of frustration I found out that using Forms inside other Forms (instead of Fieldset inside Form) seemed to be the problem. This is kinda weird for me, since Form extends Fieldset I automatically assumed I could nest Forms in Forms too - but instead of giving me an error it just does not work!
One of the main problems seems to be the difference in bindValues in both.
Originally posted by @scroach at zendframework/zend-form#192
The text was updated successfully, but these errors were encountered: