Welcome Guest, Not a member yet? Register   Sign In
Yet another form validation question ... You know you can help! :)
#1

[eluser]winterain[/eluser]
Is it possible to pass a success/false from a controller back into the ajax.updater that calls it ?

This ajax.updater calls the controller upon form submit:
Code:
function comment() {
    var params = Form.serialize($('form_comment'));
    new Ajax.Updater ('comm_f_status', base_url+'/sendcomment', {method:'post', parameters:params});
    new Effect.Appear('comm_f_status');
    Form.reset($('form_comment'));
}

What I have in the controller is like this,
Code:
if ($this->form_validation->run() == TRUE)
    {
        $this->Songsdb->insertComment($data);
        return $success = TRUE;
        echo 'Your Comment has been added! :)';
    } else
        
    if ($this->form_validation->run() == FALSE)
    {
        return $success = FALSE;
        echo validation_errors();
    }

I want the Form.reset to only occur if the insert was successful, and not if there are errors.. I don't want to reload the page.

Is this the way to go about this type of functionality? Help ?


Messages In This Thread
Yet another form validation question ... You know you can help! :) - by El Forum - 01-08-2009, 12:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB