⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to create 2 required fields



vhanxer
  • profile picture
  • Member

Posted 07 December 2012 - 05:14 AM

hello.. a newbie here..
I want to ask

$state=$crud->getState();
if($state == 'edit')
{
$crud->required_fields('username','name','email');
}
if($state=='add')
{
$crud->required_fields('username','password','name','email');
}

as you can see there, I want to make 2 difference required fields
so, when add new user, the password is required but
when edit user, the password NOT required...

but when I using this code, for add and edit, the required code not working..
when I remove the state the required code is working..

so I'm assumming that the state code is not working..
or I wrong using the state code..

please.. any help?

victor
  • profile picture
  • Member

Posted 07 December 2012 - 13:30 PM

show your controler.

tofayelahmed
  • profile picture
  • Member

Posted 08 December 2012 - 04:28 AM

Hello vhanxer.
May be I understand your problem.
Use this code and Check .

$state=$crud->getState();
if($state == 'edit' || $state=='update_validation')
{
$crud->required_fields('username','name','email');
}
if($state=='add' || $state=='insert_validation')
{
$crud->required_fields('username','password','name','email');
}

Cheers.

vhanxer
  • profile picture
  • Member

Posted 10 December 2012 - 03:26 AM

[quote name='tofayelahmed' timestamp='1354940894' post='4617']
Hello vhanxer.
May be I understand your problem.
Use this code and Check .

$state=$crud->getState();
if($state == 'edit' || $state=='update_validation')
{
$crud->required_fields('username','name','email');
}
if($state=='add' || $state=='insert_validation')
{
$crud->required_fields('username','password','name','email');
}

Cheers.
[/quote]
Thanks man... you solved my problem... :D