Jump to content


rule is_unique problem

rules is_unique set_rules

  • Please log in to reply
5 replies to this topic

#1 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 29 July 2013 - 03:32 PM

$crud->set_rules('user', 'User','is_unique[tbl_user.user]');

the rule "is_unique", works ok, but when edit a record (user) with the GC, this rule is activated, this record being unique.
the rule "is_unique", should only be activated by insert in GC in this case.

how to solve this problem?, I need the user editbox, is unique.

 

and

 

how I create my own rule?

 


sorry my bad english



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 29 July 2013 - 09:54 PM

Hello kenshicu.

It is normal behaviour while in edit mode to have the rule activated.

If you feel that this is not what you need to have as a validation then use the callbacks as here.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 30 July 2013 - 12:54 PM

ok, but as I do this of Codeigniter in groceryCRUD:

$this->form_validation->set_rules('username', 'Username', 'callback_username_check');

public function username_check($str)
	{
		if ($str == 'test')
		{
			$this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}

In GroceryCRUD would look like?

$crud->set_rules('user', 'User','callback_username_check');   

 

To create my own rules.



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 30 July 2013 - 02:07 PM

Yes. If you read on the set_rules page, it says:

"Set Validation Rules works with the exact same way as Codeigniter set_rules"


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 30 July 2013 - 02:37 PM

Yes, I read it, but the rules with callback not work in GroceryCRUD

if anyone has any example would appreciate
.



#6 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 09 April 2014 - 08:14 PM

well brother u can check the solution in here







Also tagged with one or more of these keywords: rules, is_unique, set_rules

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users