CodeIgniter Forums
Form Validation on API PUT Verb - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Form Validation on API PUT Verb (/showthread.php?tid=62922)



Form Validation on API PUT Verb - prezire - 09-08-2015

Is there any way to validate form fields using PUT? I normally do something like this in POST:
public final function update($id = NULL)
{
if($this->input->post())
{
if($this->form_validation->run('user/update')){...}
else
{
//Show view with validation_errors().
}
}
}
?>
But with PUT, it doesn't work:
public final function apiUpdate()
{
if(strtolower($this->input->method()) === 'put')
{
if($this->form_validation->run('user/update')){...}
else
{
//validation_errors() comes out empty.
}
}
}


RE: Form Validation on API PUT Verb - PaulD - 09-15-2015

I am sorry I personally cannot help with this, but this might be of use to you:
http://stackoverflow.com/questions/7033138/codeigniter-validate-put-data

Best wishes,

Paul.


RE: Form Validation on API PUT Verb - mwhitney - 09-16-2015

You need to use $this->form_validation->set_data() to pass the data to the form_validation library (or put the data into the post array as recommended by the link supplied by PaulD), since it only checks for post data by default.


RE: Form Validation on API PUT Verb - Vimal - 09-18-2015

Use
PHP Code:
$this->form_validation->set_data($this->put());