Wednesday, May 14, 2014

Re: When is a form post not a form post?

I am not quite sure why you are making this into your own science project :)
it is fairly simple actually

have an "id" field in your table => edit => PUT
dont have an "id" field in your table => add => POST

That's documented - and exactly as easy and straightforward as it sounds

If you don't care about PUT/POST in your actions, you can indeed just check for both (as I have always done so far):

    if ($this->request->is(array('post', 'put')) {}

This works for all edit and add actions. Always.

Done in a few seconds.. :)



Am Mittwoch, 14. Mai 2014 02:09:51 UTC+2 schrieb Reuben:
So, having decided to always specify the action is the Form::create, so I can only be concerns with detecting a POST for form submissions, I'd really like to make sure that is covered in my unit testing.

But that's a tricky one.

I guess I would need to write a unit test for any view that has a form, and mock the FormHelper to expect that any create() had an array with an action entry to specify the expected action.  Writing unit tests for views is generally frowned on, so much so, that an example of how to do this is not given in the doco.

If the issue holds my attention long enough, I'll post back.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: