cakephp-2.4

Different validation messages in different web browsers

孤者浪人 提交于 2019-12-13 04:25:55
问题 I am a newbie in CakePHP and doing my first application - first blog from cakephp tutorial. Everything is fine, but one thing bothers me. When I define validation rules in my model, validations are working. But every web browser show different message. For example firefox show message in czech language (i'm from czech), chrome show "Please fill out this field" and internet explorer show "This field cannot be left blank".So i tried to translate the messages (by add parameter message into model

CakePHP Edit Not Loading foreign Table Data

白昼怎懂夜的黑 提交于 2019-12-12 04:46:05
问题 I am trying to get my edit to work I need the contact detail data to load when the user data loads. I have set the data in a similar manner to how I am retrieving the list of roles. I also don't know how to retrieve according to the model currently I was hard-coding it to retrieve 28. Would greatly appreciate any help provided. public function edit($id = null) { //Populate roles dropdownlist $data = $this->User->Role->find('list', array('fields' => array('id', 'name'))); $this->set('roles',

cakephp-2.4:Image directory not sending after applying jshelper ajax submission

僤鯓⒐⒋嵵緔 提交于 2019-12-12 02:16:13
问题 Here cakephp image upload working fine without ajax.After using ajax, data is inserted without image directory. Here is my model code public function processCoverUpload($check = array()) { if (!is_uploaded_file($check['product_image']['tmp_name'])) { return FALSE; } if (!move_uploaded_file($check['product_image']['tmp_name'], WWW_ROOT . 'img' . DS . 'uploads' . DS . $check['product_image']['name'])) { return FALSE; } $this->data[$this->alias]['product_image'] = 'uploads/'. $check['product

CakeResque plugin not working

China☆狼群 提交于 2019-12-11 21:20:59
问题 I am trying to use CakeResque plugin in cakephp 2.4 and follow all installation instruction as per link http://kamisama.me/2012/10/16/background-jobs-with-php-and-resque-part-6-integration-into-cakephp/ When I fire command cake CakeResque.CakeResque start Getting error Error: Class CakeResqueShell could not be loaded. Any help appreciated Thank you 回答1: You have to load the CakeResque plugin into your CakePHP app first. In your app/Config/bootstrap.php, make sure that the plugin is loaded

Join single item from related table based on min of field

偶尔善良 提交于 2019-12-11 19:53:55
问题 I have an Item model which has the following associations: public $hasOne = array( 'Project' => array( 'className' => 'Project', 'foreignKey' => 'item_id' ) ); public $hasMany = array( 'ItemPic' => array( 'className' => 'ItemPic', 'foreignKey' => 'item_id', 'dependent' => false ) ); I am wanting custom data for different views of Item . It seems like CakePHP automatically includes Project data (maybe because it is hasOne ?) and does not include the ItemPic data. In the index I really don't

In CakePHP, where would I put a method that performs a check on the Session User?

久未见 提交于 2019-12-11 13:54:15
问题 Background: I have a method levelCheck() which compares the current user's level to a few parameters, and returns a true or false. I need to be able to access this method from any controller, and I would also like to put a call to it inside a helper for use on menus, etc. Question: Due to Cake's flexibility, I can call almost anything from almost anywhere with Cake. Where is the correct place to put this? In a custom Session (extended)? In the AppController? A new component dealing with the

Cakephp Upload Image - Can not determine the mimetype

ぐ巨炮叔叔 提交于 2019-12-11 13:17:34
问题 The following validation is being done in my model 'image' => array( 'uploadErrror' => array( 'rule' => 'uploadError', 'message' => 'The image upload failed.', 'allowEmpty'=> True ), 'mimeType' => array( 'rule' => array('mimeType',array('image/gif','image/png','image/jpeg')), 'message' => 'Please only upload images (gif, png, jpg).', 'allowEmpty' => true ), 'fileSize'=> array( 'rule' => array('fileSize', '<=', '1MB'), 'message' => 'Image must be less than 1MB.', 'allowEmpty' => true ),

$this->params returns null in cakephp model

假如想象 提交于 2019-12-11 02:22:35
问题 I decided to add some extra data about the controllers and actions in some model beforeSave as follows: //in the model public function beforeSave() { $this->data[$this->alias]['path'] = 'blah blan'; debug($this->params); die(); //for debugging! } The printout of debug returns null ! The model I uses is the Comment model of the comments plugin. I need to access params to get the current controller, actions and some url parameters. Indeed, I plan to change the way that comments plugin lists the

Typing the command “cake” in console shows no output

大兔子大兔子 提交于 2019-12-10 19:32:39
问题 Typing the command "cake" in console shows no output, no errors or anything like that. It just prints about 4 blank lines. Has anyone else experience this problem before and how did you fix it? C:\xampp\htdocs\project\app>cake C:\xampp\htdocs\project\app> 回答1: I have had similar problem a moment ago and I found the solution. the problem was not the path for me. I have turn on the debug from 0 to 2. and it shows some error instead of empty output and I try to fix the error (which was in the

how to implement JsonP in cakephp 2.4

浪尽此生 提交于 2019-12-09 22:37:26
问题 I have just upgraded to cakephp 2.4.1 as it now supports JsonP. I was previously getting an a missing callback error in my ajax cross domain code. However the documentation does not mention any additional steps need to implement this so I would have thought that it should wold but i get the same error as before. Do I need an extra piece of code to send the callbck back? My Controller public function api($mem_id = null) { $options = array( 'fields' => array('Member.total_points'), 'conditions'