Issues

ZF-7791: Zend_Form doesn't handle PUT/DELETE requests.

Description

Good day.

Since 1.9 and Zend_Rest_Route/Zend_Rest_Controller PUT/DELETE methods was added in Zend_Form. But i founded Zend_Form doesn't handle them as expected. It just changes 'method' form param to PUT/DELETE, instead of creating a hidden '_method' field with necessary values.

Comments

I'm interested in opinions on this. Is this a problem we should be solving at all?

Rewriting the Form decorator doesn't really work since the Form decorator is on the end of the decorator stack; decorating with a form field (either in Zend_View_Helper_Form or the Form decorator itself) is a) repeating ourselves to output a form element and b) ignoring any other elements named _method, thus potentially rendering 2 html elements with the same name.

A more elegant solution may be to add an additional decorator to the begining of the default decorator stack; which adds the element and modifies the submission method, letting the existing decorators handle rendering the element in it's own right. This decorator could be removed via removeDecorator() to return handling of 'put' and 'delete' methods to the unhandled way. It would be possible to make this decorator configurable beyond defaults, so the user can alter the type and name of the element so it is not only compatible with the Zend_Rest_Route-style handling. I'd prefer explicitly adding this decorator however adding the decorator would require clearing the stack and re-adding the default decorators, since it's currently not possible to prepend a decorator to the stack. This would make adding the decorator more effort than adding manual handling.

Opinions welcome, I'll reconsider the course of action on Friday 25th of September.

I'll extend coments for another week.

A task for ZF2.