php - Create a unique field in yii-user module -


Hi, I am using the Yii-user module I am new to this and faced some problem. I make the agent's profile field with user / profilefield / create . Now I want to make it unique

  public function rules () {/ p> 

if (! $ This-> _rules) {$ required = array ( ); $ Numeric = array (); $ Float = array (); $ Decimal = array (); $ Rules = array (); $ Model = $ this- & gt; GetFields (); Forex Currency ($ Model $ Field) {$ field_rule = array (); If ($ Field- & gt; Required == ProfileField :: REQUIRED_YES_NOT_SHOW_REG} $ Field- & gt; Required == ProfileField :: REQUIRED_YES_SHOW_REG) array_push ($ Required, $ Field-> Varna); If ($ field-> field_type == 'float') array_push ($ float, $ field-varname); If ($ Field-> Field_type == 'Decimal') array_push ($ decimal, $ field-varname); If ($ field-> field_type == 'integer') array_push ($ numeric, $ field-> vignette); If ($ Field-> Field_type == 'VARCHAR' || $ field- & gt; Field_type == 'TEXT') {$ field_rule = Array ($ field-> Vernon, 'Length', 'Maximize' = & Gt; $ field- & gt; field_size, 'min' = & gt; $ field- & gt; field_siss_man); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; } If ($ field-> other_exceptions) {if (stropo ($ field-> other_messenger, '{'} === 0) {$ validator = (array) sejawascript :: jasondicode ($ field-> ; Other_services); Forex currency ($ denisor as $ name = & gt; $ val) {$ field_rule = array ($ field-> varname, $ name); $ Field_rule = array_merge ($ field_rule, ($ array $) $ $ [$ name]); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; }} And {$ field_rule = array ($ field-> varna, $ field-> other_exhibitor); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; }} Elseif ($ field-> Field_type == 'DATE') {$ field_rule = Array ($ field- varname, 'type', 'type' => 'date', 'dateFormat' = & gt; 'Yyyy-mm-dd', 'allowEmpty = => true); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; } If ($ field-> match) {$ field_rule = array ($ field-> varna, 'mail', 'pattern' => gt; field- & gt; match); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; } If ($ field- & gt; category) {$ field_rule = array ($ field-> varna, 'in', 'category' = & gt; self :: boundary rule ($ field- & gt; category)); If ($ field-> error message) $ field_rule ['message'] = UserModule :: t ($ field-> error_message); ($ Rules, $ field_rule) array_push; }} Array_push ($ rules, array (implode (',', $ required), 'required')); Array_push ($ rule, array (implode (',', numerical, '' numeric ',' integer only '= & gt; true)); Array_push ($ rules, array (implode (',', $ float, 'type', 'type' => 'float')); Array_push ($ rules, array (implode (',', $ decimal), 'match', 'pattern' = & gt; '/^\s*[-+]?[0-9]*\.?[0} - 9] ([EE] [- +] [0-9] +?) \ S * $ / ')); $ This- & gt; _rules = $ rules; } $ This- & gt; _rules; }

This is usually a function (this works) according to your function / module The array ('field_name', 'unique', 'message' = & gt; error message entered in the case of duplicate value entered '),

  will be required to modify, / Code> 

See these links too, it can be useful to you,


Comments

Popular posts from this blog

c# - WPF Expander overlay used in ItemsControl -

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

Android studio res/xml directory not found -