CodeIgniter Forums
[Problem] Form helper in Codeigniter v3.0rc - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [Problem] Form helper in Codeigniter v3.0rc (/showthread.php?tid=936)



[Problem] Form helper in Codeigniter v3.0rc - piece601 - 01-30-2015

Hi have anyone use Form Helper in Codeigniter v3.0rc.
I have a problem about it.
When My Controller receive $_POST data,
PHP Code:
$this->form_validation->run() 
always return false ...
What's happen? I set rules correctly.
And
PHP Code:
echo validation_errors(); 
no render any message ...
Who can help me.


RE: [Problem] Form helper in Codeigniter v3.0rc - SquallX - 01-30-2015

Yes, I have the same problem after a lot of tests.

If all the input fields are empty :

[Image: an3b.png]

It's okay, all the errors are found

And if I fill all fields :

[Image: fr2w.png]

The message error is that it nof found the error message, but this message exists in english and in french language.

I've also an error with the csrf security, when i activate it in the config file. it's impossible to submit a form :/


RE: [Problem] Form helper in Codeigniter v3.0rc - Narf - 01-30-2015

Did you have 'xss_clean' included in your validation rules? Read the upgrade instructions.


RE: [Problem] Form helper in Codeigniter v3.0rc - SquallX - 01-30-2015

Yes, I've tried to deactivate it and it was the same result :/

In fact we need to deactivate global_xss_filtering in the config file and load the security helper to applicate it in the form validation rules ?

I've tried it and apparently it works.

But, when I use the csrf protection (in config file) I have this error when I try to submit a form :

The action you have requested is not allowed.

PS : Sorry for my bad english :/


RE: [Problem] Form helper in Codeigniter v3.0rc - Narf - 01-30-2015

(01-30-2015, 08:45 AM)SquallX Wrote: Yes, I've tried to deactivate it and it was the same result :/

In fact we need to deactivate global_xss_filtering  in the config file and load the security helper to applicate it in the form validation rules ?

I've tried it and apparently it works.

If I were you, I'd remove the 'xss_rule', not try to make it work again. It is very much intentional that it's no longer a form validation rule by default.

(01-30-2015, 08:45 AM)SquallX Wrote: But, when I use the csrf protection (in config file) I have this error when I try to submit a form :

The action you have requested is not allowed.

PS : Sorry for my bad english :/

Please read the manual about CSRF protection: http://www.codeigniter.com/userguide3/libraries/security.html#cross-site-request-forgery-csrf


RE: [Problem] Form helper in Codeigniter v3.0rc - SquallX - 01-30-2015

Thanks but I've already read the documentation about the csrf protection. My code is like that (I use Twig template) :

PHP Code:
         $this->data array_merge($this->data, [
 
               'page_title'    =>  'Rejoindre la communauté',
 
               'set_login'     =>  set_value('u_login'),
 
               'set_email'     =>  set_value('u_email'),
 
               'set_password'  =>  set_value('u_password'),
 
               'set_pass_conf' =>  set_value('pass_conf'),
 
               'csrf_name'     =>  $this->security->get_csrf_token_name(),
 
               'csrf_hash'     =>  $this->security->get_csrf_hash(),
 
           ]);

 
           $this->twig->display('site/user_register.twig'$this->data); 

And my users_panel.twig contains between form tags :

Code:
<div class=" col-sm-offset-2 col-sm-10">
                           <input type="hidden" name="{{ csrf_name }}" value="{{ csrf_hash }}" />
                           <button type="submit" name="submit_new" class="btn btn-primary">S'inscrire<i class="icon-after fa fa-chevron-right" style="color:#FFF"></i></button>
                       </div>

So I don't understant why the access is already refused :/