Welcome Guest, Not a member yet? Register   Sign In
problem with form and validation
#1

Hello.
I am using CI4. I have a form with a dropdown and I can't get validation to work.

I tried putting a required in the dropdown itself and it didn't work either. The code goes below.

PHP Code:
$val=$this->validate([
                        'fk_orcamento'=>'is_natural',
                        'fk_orc_prod'=>'is_natural',
                        ]        
                    
);
                    //Se não passar na validação retorna para a página anterio (back) com os erros.
                    if(!$val){
                        helper('[old]');
                        return redirect()->back()->withInput()->with('errors'$validation->getErrors());
                    }
                    $dados=[
                        'fk_orcamento'=>$post['fk_orcamento'],
                        'fk_orc_prod'=>$post['produto'],
                    ]; 

PHP Code:
<?php echo form_dropdown('produto',$dropProdutos,'null',['class'=>'form-control']) ?>
Reply
#2

Solved: I forgot that zero is also a natural number. I had to use "is_natural_no_zero".
Reply
#3

Please edit your post title and add [SOLVED] to it so other users can see its been solved.

Thank you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB