cakephp-2.0

CakePHP: Creating new HABTM row instead updates other

谁说我不能喝 提交于 2019-12-21 05:42:23
问题 I have two models with a HABTM (Has and belongs to many) relationship: Qsets and Questions. The following action (in QsetsController.php) should result in a new row in the qsets_questions table, with the new question appearing in the new qset. But instead it updates existing rows, resulting in that question begin taken from a previous qset and added to the new one. What am I doing wrong? public function admin_add_question( $qset_id, $question_id) { //find the qset... $qset = $this->Qset->find

Custom Pagination in Cake PHP

一个人想着一个人 提交于 2019-12-21 05:13:24
问题 i'm a beginner in cakePHP , and i wan't to create a custom pagination in cakePHP . the function $paginator->numbers() ; it displays the page numbers like this : 1 | 2 | 3 | 4 | ... by looking in the options , there is some options to change the separator, to add a class of a style css ..Etc . what i want is to have my pagination like this : 1-20 21-40 41-60 61-80 ... >> some one has an idea about how to code it ? EDIT : i've created the custom paginator helper in : app/View/Helper/ , and i've

Localizing timeAgoInWords in CakePHP

℡╲_俬逩灬. 提交于 2019-12-21 04:56:15
问题 In my CakePHP application, By using cake.bat i created POT files and by using PoEdit I created PO files. So by writing __('myword') i can see localized word in my application successfully. But now I need to localize "timeAgoInWords". When i run cake i18n extract , script didn't get the _dn() words in CakeTime http://api20.cakephp.org/view_source/cake-time#line-522 So i created a dummy.ctp file and copy-pasted contents from cake-time file to dummy file. I run cake script and POEdit again. And

CakePHP: How to update multiple records at the same time with the Form helper

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 02:44:12
问题 On an edit page for the model Test I want to be able to update the "Questions.order" field on all of it's associated (by hasMany) questions from the same form. I've ready the Cake book chapter on saveMany()/saveAll() in the book, and I'm using the Model.0.field syntax but I can't figure out how to tell CakePHP which record to corresponds to which input. Should the # in Model.#.field correspond to the question's id field? Here's what I'm currently doing: echo $this->Form->create( 'Question',

CakePHP with Bootstrap (from Twitter)

社会主义新天地 提交于 2019-12-20 10:38:12
问题 I am new to CakePHP and I want to know a way to use Boostrap from Twitter in layouts combined with cake. My main concern is to make the Form Helper continues to function normally, because I think that it uses pre-configured CSS classes, and if I change the default css, I imagine that the Form Helper will stop to work as it should. I read this tutorial but it doesn't seems to be complete. Build a PHP application using CakePHP and (twitter) Bootstrap, Part 1 Has anyone done this? Thank you! :D

cakephp 2.0 how to update auth data?

你。 提交于 2019-12-20 09:19:18
问题 when I update data in the User model, the Auth data is not updated. How can I "refresh" the data which is returned by $this->Auth->user() when I am updating user model ? and I don't want to use $this->Auth->login($data); after updating my user table 回答1: I tried the following line. Its works well form me After modify the user data i written the following line $this->Session->write('Auth', $this->User->read(null, $this->Auth->User('id'))); 回答2: Write the updated data to the Session eg: $this-

Caching plugin and normal controllers with duplicate names

丶灬走出姿态 提交于 2019-12-20 07:37:24
问题 I'm running into a problem related to caching, plugins and duplicate model names in Cake 2.0. My application has several controllers containing only actions for public use (view, index and equivalents). The data is managed by a CMS which is added as a plugin, some names of the plugin's controller are the same. For example, I have a PostsController in my application and a PostsController for the plugin. The plugin controller extends PluginAppController and the public controller extends

CakePHP re-populate list box

与世无争的帅哥 提交于 2019-12-20 07:09:27
问题 I have a question about cakePHP. I create two drop down lists in my view. When the user changes the value in one list, I want the second to change. Currently, I have this working like this: An on click event fires when the user selects from list box one. This fires a jQuery ajax function that calls a function from my controller. This is all working fine, but how do I re-render my control, asynchronously (or, view)? I i know I could just serialize the array to json and then recreate the

Auth login with email or mobile Cakephp

最后都变了- 提交于 2019-12-20 06:16:20
问题 I am working on cakephp 2.x.i have a table in my database name user and it has 4 fields id, email, password and mobileNo i have two fields in my login.ctp <?php echo $this->form->create(); echo $this->form->input('email'); echo $this->form->input('password'); echo $this->form->end('submit'); ?> what i want is i want to login the user from his mobileNo too(if he typed mobile number rather then email address) just like facebook has done ..he can either login with hi email address or mobileno .i

Instantiating a vendor class in class constructor

天大地大妈咪最大 提交于 2019-12-20 05:42:13
问题 In my CakePHP 2 application I have such vendor. I need to create an instance of this vendor class inside my controller class. So I will use that instance inside my controller's different functions. App::import('Vendor', 'fancyVendor', array('file' => 'fancyVendor.php')); class MyController extends AppController { public $fancyVendor; function beforeFilter() { $fancyVendor = new fancyVendor(); $fancyVendor->setValue("12"); } function showMe() { echo $fancyVendor->getValue(); } } Inside my