cakephp-2.1

sending data via ajax in Cakephp

99封情书 提交于 2019-12-06 11:59:49
i am new to cakephp and trying to send data from ajax to my controller action.. i have a popup model in which there is a input box ..i want to grab that value and send to controller without page refresh here is my code .. <a class="button anthracite-gradient" onclick="openPrompt()">submit </a> my javascript function openPrompt() { var cancelled = true; $.modal.prompt('Please enter a value:', function(value) { $.ajax({ type:"POST", url:"/cakephp/controller/action/", success : function(data) { alert(value); //value right now is in this variable ... i want to send this variable value to the

CakePHP 2.1 find using contain with condition

心不动则不痛 提交于 2019-12-06 08:17:41
I have the following models. Industry(id, name) Movie(id, name, industry_id) [Industry has many movies] Trailer(id, name, movie_id) [Movie has many trailers] I need to find 6 latest trailers for each Industry . Every movie does not need to have a trailer or can have multiple[0-n]. The results must contain array of movies with atleast one trailer. $this->Industry->find('all', array( 'contain' => array( 'Movie' => array( 'Trailer' => array( 'limit' => 1 ), 'order' => 'Movie.release DESC', 'limit' => 6 ) ), 'order' => 'Industry.name ASC' )); Option 1 (best option IMO): You were on the right track

Cakephp - HABTM record won't delete with unique set to true

谁说胖子不能爱 提交于 2019-12-06 08:03:19
CakePHP has the default of unique set to true, I've coded it just to make sure as well. So I have the following DB structure: Item HABTM Action, with unique set to true. The situation is as followed: Deletion works fine upon save when I delete 1 or more records, if ATLEAST 1 record stays 'alive' Deletion doesn't work upon save when I delete all records ( or 1 record, if that's the only one). It simply keeps all existing records that way. I've made sure with debug($this->request->data) right before save that it contained Nothing of Action. From the discussion in the comments on your post I am

CakePHP 2 $this->Html->script order

岁酱吖の 提交于 2019-12-06 03:42:48
问题 I am trying to insert JS files into the view but they are being inserted in the wrong order. In my default.ctp I have this $this->Html->script(array( 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', 'global' ), array('inline'=>false)); echo $this->fetch('script'); In my view I have this: $this->Html->script('jquery.fancybox.pack', array('inline' => false)); But when I view the source it comes out like this: <script type="text/javascript" src="/js/jquery.fancybox.pack.js"><

User sessions and two CakePHP applications running in the same machine

跟風遠走 提交于 2019-12-05 20:29:33
I have 2 CakePHP applications running on the same machine. Both of them need a previous registration to have access to them and the first thing users see is the login form. I have realized that when I do login in one of them, then, I can access to the other web application without being asked for my credentials to login. (which is not correct) In my Controllers of both applications I have this to deny access without a previous login. public function beforeFilter(){ parent::beforeFilter(); $this->Auth->deny(); } But this seems not to work properly when I use the same browser and I do login in

cakephp doesn't work url-rewriting on Ubuntu

别来无恙 提交于 2019-12-05 18:22:49
问题 all. This time I try cakephp, but I have got "URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting". I could know this is apache and .htaccess issues such as /etc/apache2/sites-avaliable/default and each directory .htaccess. My development environment... Ubuntu12.04 on vmware fusion4 apache2.2.22 mysql5.5 php5.3.10 cakephp2.1 My process is followed... 1)/etc/apache2/httpd.conf <Directory /> Options FollowSymLinks AllowOverride

right way to install cakephp-scripts for v2.2.1?

三世轮回 提交于 2019-12-05 13:33:09
I am using ubuntu and as per instruction I use 'apt-get isntall cakephp-scripts' I am using latest stable release of cake v 2.2.1, but when I run cake bake -app , I always get console for v1.3.2 Why do I get CakePHP v1.3.2 Console on cakephp v 2.2.1 As the others already pointed out, CakePHP from the repositories is v1.3.2 which doesn't work with your 2.1. After uninstalling ( sudo apt-get remove cakephp-scripts ) it, do the following: Download CakePHP 2.1 and extract it somewhere globally available (e.g. /usr/share/php/cakephp/ Check the permissions: /usr/share/cakephp/ and all subfolders

Best way to implement admin panel in CakePHP

青春壹個敷衍的年華 提交于 2019-12-04 22:34:12
问题 I am trying to move from CodeIgniter to CakePHP and can't figure out the best way to implement an admin panel. In CI I would create two different applications, one for the frontend and one for the admin panel. After Googling around, I have found three ways to implement admin panel in CakePHP: Routing - I don't want to use this as I want by Controllers/Models to be separate for frontend and admin panel Plugin Two separate apps Should I use plugin to implement admin panel or should I have

Dynamically add virtual field in cakephp

左心房为你撑大大i 提交于 2019-12-04 22:26:01
I am using CakePHP 2.1.3; I want to create a virtual field dynamically in a controller. Is it possible? The problem is when I am trying to find max value in a table it gives me another array from the model array. Please ask if you need more information. When I am trying to execute the following query, $find_max_case_count = $this->CaseMaster->find('first', array( 'conditions' => array( 'CaseMaster.CLIENT_ID' => $client_id, 'CaseMaster.CASE_NO LIKE' => '%-%' ), 'fields' => array('max(CaseMaster.CASE_NO) AS MAX_NO') )); It is giving me an array like: [0]=> array([MAX_NO]=> 52) However I want it

CakePHP 2.1 Ajax validation errors

筅森魡賤 提交于 2019-12-04 21:05:24
I'm trying to get validation errors with Ajax and jQuery working in CakePHP 2.1 for a contact form. On blur of the name field a js function is called: $(document).ready(function(){ $('#name').blur(function(){ $.post( '/Cake_ajax/Contacts/validate_form', { field: $(this).attr('id'), value: $(this).val() }, handleNameValidation ); }); function handleNameValidation(error){ if(error.length > 0){ if($('#name-notEmpty').length == 0){ $('#name').after($('<div id="name-notEmpty" class="error-message">' + error + '</div>')); } }else{ $('#name-notEmpty').remove(); } } }); The javascript calls the