Welcome Guest, Not a member yet? Register   Sign In
Advice on doing this better, faster and neater (form and image upload)
#4

[eluser]bugboy[/eluser]
when moving the vaildation sets to a function would i just run that function everytime the controller is called and get the function to return the

$this->validation->run();

TRUE or FALSE

so something like this

Code:
function _news_validaton()
{
    // validation area
    $rules['title'] = "trim|required|xss_clean";
    $rules['tag'] = "trim|required|xss_clean";
    $rules['dscpn'] = "trim|required|xss_clean";
    $rules['text'] = "trim|required|xss_clean";
    $rules['keyword'] = "trim|xss_clean";
    $this->validation->set_rules($rules);  
    $fields['title'] = 'title';
    $fields['tag'] = 'tag';
    $fields['dscpn'] = 'description';
    $fields['text'] = 'text';
    $fields['keyword']  = 'keyword';
    $fields['day'] = 'day';
    $fields['month'] = 'month';
    $fields['year'] = 'year';
    $this->validation->set_fields($fields);

    return $this->validation->run();
}

then in the controller do this

Code:
$validate = $this->_news_validaton()

if ($validate== FALSE )
{
//carry on with code
}




EDITED: yep that works a treat. plu it cuts down on the amount of of code so i can run it for the edit part as well.


Messages In This Thread
Advice on doing this better, faster and neater (form and image upload) - by El Forum - 05-14-2008, 08:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB