Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Why function always send us to template
  • Hi,

    I need help to understand how fuelphp works with template and returned values.
    I have a form in a view that send two fields to a function of my controller.

    I put a validation object in it and I have a strange behavior.
    Actually when the validation is ok I can return true but when it is not, I try to return false but the controller is trying diplay the template.

    He is my code

     

    if (\Fuel\Core\Input::post())
            {
                //$val = Validation::forge('my_validation');

                $val = Validation::forge('my_validation');
                $val->add_field('emailAdress','' , 'required');
                $val->add_field('password', '', 'required|min_length[3]|max_length[10]');

                if ($val->run())
                {
                    //var_dump($val->validated());
                    //var_dump($val->input());

                    return true;
                }
                else
                {
                    //var_dump($val->input());
                    //var_dump($val->error());
                    return false;
                }
            }

     

    I need to understand. please help.
    Thank you in advance

     

     

     

  • HarroHarro
    Accepted Answer
    Controller actions always have to return a Response object. If you use a base controller, it's after() method will construct a Response object for you if you haven't done it.

    So I don't know what you intend to achieve by returning true or false, but it will not do anything. Perhaps you should start explaining what you want to do?
  • Hi,

    Thank you very much for your answer, it helped a lot ! From there and with the documentation I have been able to understand what I was doing wring.

    Thanks again :) 

Howdy, Stranger!

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

In this Discussion