cakephp-2.1

Reordering Behaviors in CakePHP

老子叫甜甜 提交于 2019-12-14 03:09:53
问题 I'm writing a plugin which includes a behavior that has a dependency on the ContainableBehavior . In my behavior, I'd like to tweak any query conditions in its beforeFind() callback, but I'm finding that ContainableBehavior::beforeFind() has already been executed so my changes of course are falling on deaf ears, so to speak. The only solution, as far as I can tell, is to manually change the behavior execution order so that my behavior's beforeFind() method is called before ContainableBehavior

CakePHP Image/File Uploader Plugin

谁都会走 提交于 2019-12-14 02:43:21
问题 I am looking for a decent working Image/File uploader for CakePHP 2.1. I am using Meio Uploader and it gives me weird errors all the time -> Invalid File type even though i have configured to upload a JPG file. 回答1: You can try Cake PHP media plugin which is a fork for Cake 2.0 of popular Cake media plugin by David Persson. I am using the original plugin on a 1.3 installation and it works great. 回答2: Ajax File Upload using jQuery and CakePHP Media Plugin http://pixelcone.com/tutorial/ajax

Uncaught SyntaxError: Unexpected token ILLEGAL

霸气de小男生 提交于 2019-12-13 16:25:16
问题 I am encountering a problem similar to this: Uncaught SyntaxError: Unexpected Token - jQuery - Help! I am using CakePHP 2.x to generate a jquery AJAX request. It works fine on my local setup, but fails on a production server, giving me an uncaught SyntaxError: Uncaught SyntaxError: Unexpected token ILLEGAL This is the PHP: // Get the select element by its generated id attribute. echo $this->Js->get('#'.$equipment_code)->event( // Change in the dropdown selection 'change', // Request an array

Cakephp: Validating an input field depending on an option selected from a dropdown list

可紊 提交于 2019-12-13 04:18:25
问题 Hie guys i need help with my code I don't know how to do it. I have a form where a student selects an exam body, if the exam body selected is zimsec marks should be empty and if the exam body is cambridge marks should not be empty and should take a range depending on grade. validMarks is the function I am using to validate marks and it stopped working when i allowed marks to be empty so as to accomodate Zimsec. My add.ctp echo "<td>"; echo $this->Form->label('Mark(%): '); echo "</td><td>";

Php Variable in Cakephp Model

老子叫甜甜 提交于 2019-12-13 02:46:39
问题 I am trying to use join with two table by using has many relation of CakePHP with condition my model code are here which am using public $userid = 3; public $name = 'Course'; public $hasMany = array( 'Enrollcourse' => array( 'className' => 'Enrollcourse', 'foreignKey' => 'course_id', 'conditions' => array('Enrollcourse.student_id' => $this->userid), 'dependent' => true ) ); OR public $userid = 3; public $name = 'Course'; public $hasMany = array( 'Enrollcourse' => array( 'className' =>

CakePHP - success with $hasOne, failure with $hasMany

a 夏天 提交于 2019-12-12 21:43:14
问题 Good morning, I am having trouble with $hasMany, even though $hasOne works fine. I have two models, Assignment and AssignmentGroup. Assignment can have one AssignmentGroup but AssignmentGroup can have many Assignments. Here are the relationships: class Assignment extends AppModel { public $belongsTo = array('AssignmentGroup'); } class AssignmentGroup extends AppModel { public $hasMany = array( 'Assignment' => array('foreignKey'=>'assignment_group_id), ); } Here's the code I'm running: $this-

Saving data to User model from Profile model Cakephp

假如想象 提交于 2019-12-12 20:17:43
问题 Iam trying to save value '1' to the 'profile_created' field of my user table when the currently logged in user creates/adds a profile, my current implementation doesnt change this value, any suggestions? Thanks in advance. Current profile adding code: public function add() { if ($this->request->is('post')) { $this->Profile->create(); $this->request->data['Profile']['user_id'] = $this->Auth->user('id'); // code implemented below $this->loadModel('User'); $data = array( 'Profile' => array('user

CakePHP 2.1: Validating forms coming from elements in a smooth way?

流过昼夜 提交于 2019-12-12 17:49:06
问题 I have the following situation. Posts hasMany Comments Comments belongTo Posts In my /Views/Posts/view, I display the Post with its Comments. Also, with every Post, a Comment Form should be displayed. Therefore, I have to use an Element add_comment.ctp to the View (correct me please if I am wrong, but see this question here). /Views/Posts/view.ctp: // add comments echo $this -> element('add_comment',array('post_id' => $entry['Post']['id']), array('cache' => array('config' => 'long'))); The

cakephp phone number validation

有些话、适合烂在心里 提交于 2019-12-12 03:46:35
问题 i am new to cakephp 2.x so i dont know how to do this .. i want to login the user from his email address and phone number..what my intention is if the number in database is this "12345" and the user is trying to login through this number "+12345" he can be login into the system.. i have written a code but i dont know how can i use this or to adjust my code within the auth component as the auth component is autometically logging the user .. here is my controller public function beforeFilter()

how to set containable behavior + cakephp2.x

偶尔善良 提交于 2019-12-12 03:05:10
问题 here is my containable condition $userStatusCondition = array('AND' => array( 'OR'=> array( 'TransactionStatus.buyer_status_id'=>$user_status_id, 'TransactionStatus.seller_status_id'=>$user_status_id, ) ) ); Merge conditions (other conditions + user_status condition) $transactions = $this->Transaction->find('all',array( 'conditions'=> Set::merge($otherConditions, $userStatusCondition), 'recursive'=>2)); in TransactionModel I set the public $actsAs = array('Containable'); public $belongsTo =