Welcome Guest, Not a member yet? Register   Sign In
Form Validation on API PUT Verb
#1

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.
}
}
}
Long live CodeIgniter!
Reply
#2

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

Best wishes,

Paul.
Reply
#3

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.
Reply
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB