I have two tables, profiles and areas, in the table of areas, I have a list of names of all countries and in the profile table I have a profile for my users and in that country there is one of the fields in 'Country'
Previously I was giving users an input box to enter country name but recently I Saw that some people are entering Œ incorrect information is a person who enters the "Jupiter" as the name of your country.
What I want to do now is in my profile model
, 'country should be present' = & gt; Parent function countrywide ($ check) {$ country = strotler ($-this-> data ['' 'rule' = & gt; 'countrywide', 'message' = & gt; 'no such country is there') Profile '] [' country ']); $ Country = array (); $ Sectors = $ this-area- gt; Search ('All'); Foreign currency ($ sectors as $ area) {array_push ($ country, strollover ($ area ['area'] ['country'])); } Return in_array ($ country, $ country); }
And I'm sure the problem here is: $ sectors = $ this-area-> Search ('all');
What is the correct way to validate the country.
BTW, I can not give a drop list of the country because it is mess with my layout / website design
What you want to do is a bad idea, because you can not guarantee that end user, by any means, create a custom function in your model
Public function myFunction ($ countryName) ) {return in_array ($ country name, $ country list); }
Where $ countriesList
is an array of country names.
In Model Verification, you can do the following
public $ validate = array ('country' = & gt; array ('rule' = & gt; 'myfunction ',' Message '= & gt;' Custom message here '));
Edit:
Then I will create a custom search function in the field model, and call it from the current model to get the array of results for verification. Something like this:
$ countries list = $ this- & gt; Region-> Custom function ();
or $ countriesList = $ this- & gt; Region-> Search ('list);
Comments
Post a Comment