How to use form_validation with PUT data for use with RESTful API? |
[eluser]benners[/eluser]
I'm creating a RESTful API http://net.tutsplus.com/tutorials/php/wo...igniter-2/ I'm having problems displaying form_validation errors and I'm thinking the problem is that the data is PUT rather than POST. Can anyone assist? Code: To create a new user the API receives a PUT request.
[eluser]benners[/eluser]
I've realised that I should be using POST to create a record rather than PUT and so the validation now works. I still don't know how I'd access form_validation when doing an update with PUT so would appreciate any suggestions.
[eluser]LuckyFella73[/eluser]
According to the tutorial updates of data are made with POST request. That way you can use the form_validation as well.
[eluser]CroNiX[/eluser]
Someone modded form val to use PUT, but not sure if they will merge it in due to the comments in the pull request by narfbg. https://github.com/EllisLab/CodeIgniter/pull/1582
[eluser]benners[/eluser]
Thanks. It seems it isn't as simple as POST is Update and PUT is Create. http://stackoverflow.com/questions/63045...st-in-rest
[eluser]Drinian[/eluser]
Couldn't you just write the PUT values into the $_POST array and then use form validation? Is this a bad hack?
[eluser]Drinian[/eluser]
Looks like this has been fixed in the REST server: Phil Sturgeon's REST server on GitHub EDIT: This still has to be merged into CodeIgnitor I believe. The fix is actually in Form_validation.php. |
Welcome Guest, Not a member yet? Register Sign In |