Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Calling individual field errors using Validation
  • So rather than just returning an object of everything
    $val->error()
    
    , how do I return an error for an individual field?
  • It's not working for me the way it is described. var_dump($val->error('email')); output: Well, everything under the sun. It returns an object of everything in the entire validation. If I foreach() it, returns an error. Using FuelPHP 1.1 RC1
  • Just to clarify here’s the whole thing:
    $val = Validation::forge();
    
    $val->add('email', 'Email')
     ->add_rule('required')
     ->add_rule('valid_email')
     ->add_rule('min_length', 3)
     ->add_rule('max_length', 255);
    
    if ($val->run())
    {
     $vars = $val->validated();
     echo 'okay'; exit;
    }
    else
    {
     $data['error']['email'] = $val->error('email');
     var_dump($val->error('email'));
     
     $this->template->section = View::forge('sign/up');
    }
    
  • Just read the docs, it's explained and even emphasized.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion