cakephp-2.0

Cakephp How to validate my D.O.B field so that the age will not be greater than the period of residence entered

只愿长相守 提交于 2019-12-08 04:52:48
问题 i have two fields in my form that should correspond to each other.If a users enters the date of birth,in the D.O.B field,he/she must not be allowed to enter a period of residence greater than the D.O.B my two fields in the add.ctp are as follows echo $this->Form->input('DOB',array('label' => 'Date of birth*', 'minYear' => 1900, 'maxYear' => 2000)); echo $this->Form->input('period_of_residence', array('label' =>'Period of residence in Zimbabwe')); So now i don't know how i validate the two so

Trouble with Internationalization on CakePHP 2.0

隐身守侯 提交于 2019-12-08 04:41:02
问题 The internationalization process is not working. I ran cake i18n export . After that I put the translations into the file ".po" in the folder app/locale/por/LC_MESSAGES/default.po. . I called the method beforeFilter() in the AppController Configure::write('Config.language', 'por'); . But the translation isn't shown in __() -methods. 回答1: Here are some possible suggestions: • Clear the Cake cache in PATH_YOUR_APP/tmp/cache . Delete the files in models and persistent , but not the directories

CakePHP automating i18n extract shell process from batch file

巧了我就是萌 提交于 2019-12-08 04:40:42
问题 To create default pot file for CakePHP 2.3 i18n, in windows I created a bat file like this. CD F:\mywork\app\View F:\mywork\lib\Cake\Console\cake.bat i18n extract But I get this error: Your database configuration was not found. Take a moment to create one. --------------------------------------------------------------- Database Configuration: --------------------------------------------------------------- Name: [default] > But inside app\Config\database.php file I have database configurations

Disabling Security Salt for plain MD5 hashing in AuthComponent?

放肆的年华 提交于 2019-12-08 04:07:25
My CakePHP 2.1 app shares its user database table with another app. In order for users to be able to login into both applications, the password field needs to be hashed in plain MD5. Changing the other app or the database is not an option. I am able to change the hashing algorithm from SHA1 (the default?) to MD5 by the following: <?php // AppController.php public function beforeFilter() { Security::setHash('md5'); } ?> And I can add new users to the system with plain MD5 passwords: <?php // User.php public function beforeSave() { if (isset($this->data['User']['password'])) { $this->data['User'

Passing array to requestAction in CakePHP

帅比萌擦擦* 提交于 2019-12-08 02:48:14
问题 I have function public myfunction($myArray) { } I need to pass array("cat", "dog") To action. $output = $this->requestAction( array('controller' => 'app', 'action' => 'myfunction'), array("cat","dog") ); But this passes only cat to my controller action, dog wasn't passed. I tried this: $output = $this->requestAction( array('controller' => 'app', 'action' => 'myfunction'), array("myArray" => array("cat","dog")) ); But it didn't help. I checked cookbook but couldn't find relevant example. How

CakePHP - Include class from a directory outside the app directory

丶灬走出姿态 提交于 2019-12-08 01:41:06
问题 I am trying to include a miscellaneous library class from outside my app (it gets used by different apps). My app is located at: /var/www/websites/my_website/app/ And the class is located at: /var/www/websites/libs/CakePHP/MyClass.php In my bootstrap I'm struggling to figure out how to add the path for loading the classes from that directory: App::build(array('Lib' => array('/var/www/websites/lib/'))); App::uses('MyClass', 'CakePHP'); $myClass = new MyClass(); 回答1: Loading shouldn't be done

CakePHP find joined records with conditions on each table

人走茶凉 提交于 2019-12-07 20:03:40
问题 I want to see all the records from a join, setting a WHERE condition on each side of the join. For example, I have LOAN and BORROWER (joined on borrower.id = loan.borrower_id ). I want the records where LOAN.field = 123 and BORROWER.field = 'abc' . The answers here (this one, for example) seem to say that I should use Containable. I tried that. Here's my code: $stuff = $this->Borrower->find('all', array( 'conditions' => array( 'Borrower.email LIKE' => $this->request->data['email'] // 'abc' ),

about HMVC in codeigniter and cakephp?

你。 提交于 2019-12-07 18:26:10
问题 i heard today from my friend about HMVC in codignitor..i surprise for this feature..it is very helping in the big projects .. and i am Sad because i cant found any article or anything tell me there are HMVC in cakephp..so i have two questions.. Anyone have idea for HMVC in cakephp? Is these Brings me to learn codignitor ? Do the plugins, such as HMVC? login example in codignitor HMVC <?php hmvcExample/application/modules/login/controllers/ hmvcExample/application/modules/login/models/

Security.salt value in controller

风流意气都作罢 提交于 2019-12-07 18:09:25
In cakephp there is one file core.php It contains Configure::write('Security.salt', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); How can i get the value of Security.salt in controller in cakephp. Thanks Just try like this Configure::read('Security.salt'); it will give you the value. For more info check here Stephan The above answers have not proven to be successful in CakePHP3. Configure::Read('Security.salt') will return a blank value. In-order to read the salt from the configuration file you'll need to include the Security namespace: use Cake\Utility\Security; And you can retrieve the value

CakePHP find returns results with missing fields

青春壹個敷衍的年華 提交于 2019-12-07 15:18:29
问题 I need to get my User info and when I call $this->User->find('first', array('conditions' => array('User.id' => $user_id))); the result contains just some of the fields. I've currently updated database schema. On dev server it runs fine and returns all fields but on the production server those new fields are missing. Those servers have exactly the same configuration. I've already tried to remove contents of app/tmp/cache/models and I am using File engine for caching. The schema.php file is up