cakephp-1.3

Open pop-up at remote pc in php

会有一股神秘感。 提交于 2019-12-23 04:23:01
问题 First , I explain you Flow . I have UserX,who is online at X country and UserY,who is online at Y-country. ---------------- what i want : When UserX click on ajax button.Popup is open at UserY's PC. ----------------- Condition : I dont want to set timeout ajax request ,because of this,server become slow. ------------------ It is possible. If you have any idea about it. Thanks in advance. 回答1: Consider using Comets, here is some example 来源: https://stackoverflow.com/questions/7007160/open-pop

Routes in not redirect to index.html page

旧街凉风 提交于 2019-12-23 04:22:58
问题 I am coding on cakephp 1.3. I have a problem redirecting the page to index.html. My index.html is inside webroot folder. What I know cakephp will directly redirect to index.html. When I using URL it is showing error.. Error: Controller could not be found. Error: Create the class Controller below in file: app/controllers/controller.php <?php class Controller extends AppController { var $name = ''; } ?> I have followed some link but it not seems to work. I have checked on Google also. How can I

Cakephp Dropdowns not showing right data when Refreshing the page

帅比萌擦擦* 提交于 2019-12-23 04:07:07
问题 Ive two dropdown lists one for country and other for cities on my page. When i load the page initially i set the country to the default country loaded from the user registeration. Then i load the cities for that country. The problem is that now when i change the country dropdown and refresh the page my country dropdown selected value remains the same which has changed but the cities are loading from the default country. I'm getting the right value at the view from the controller but view is

Can Cake Php Validation clear input field value

落爺英雄遲暮 提交于 2019-12-22 21:44:46
问题 Can Cake Php Validation clear input field value var $validate = array( 'name' => array( 'isUnique' => array ( 'rule' => 'isUnique', 'message' => 'This Person name already exists.' ) ) ); If error persist in validation, I want to clear name field value. Is it possible to do so with cake php validation itself ? 回答1: You can do it with a custom validation rule if you wanted. var $validate = array( 'name' => array( 'isUnique' => array ( 'rule' => 'ifNotUniqueClear', // use custom rule defined

jQuery POST to CakePHP $this->data

核能气质少年 提交于 2019-12-22 10:38:15
问题 I'm trying to use jQuerys post-function to post a form to a CakePHP-script. Like this: jQuery: $('#submit_btn').click(function(){ //Code to prevent redirect dataString = 'test=testdata'; $.post('cakephp/forms/output', dataString, function(response){ alert(response); }) }); CakePHP function output(){ pr($this->data); # Print nothing pr($_POST); # Print test => testdata $this->render('view','ajax'); # Render ajax-friendly } So $_POST isn't empty but $this->data is... how come?? The form element

jQuery POST to CakePHP $this->data

 ̄綄美尐妖づ 提交于 2019-12-22 10:36:34
问题 I'm trying to use jQuerys post-function to post a form to a CakePHP-script. Like this: jQuery: $('#submit_btn').click(function(){ //Code to prevent redirect dataString = 'test=testdata'; $.post('cakephp/forms/output', dataString, function(response){ alert(response); }) }); CakePHP function output(){ pr($this->data); # Print nothing pr($_POST); # Print test => testdata $this->render('view','ajax'); # Render ajax-friendly } So $_POST isn't empty but $this->data is... how come?? The form element

How to use a helper function in a controller?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 04:16:28
问题 I wrote some function in app_helper file. now i need to call that function in my controller how i can do this in CAKEPHP 回答1: You can't.* If your functions are so universal as to be used outside of views, create them in bootstrap.php or make a custom library/class in the libs/ directory. * You can load anything anywhere using App::import('Helper', 'NameOfHelper') or ClassRegistry::init , but you really shouldn't. The point of MVC separation is to keep your app well organized. 回答2: App::uses(

CakePHP Login with both username and email using Auth Component

放肆的年华 提交于 2019-12-21 22:59:50
问题 I want the auth component to allow user to login entrying either username or email. In my users table, both fields - userName and userEmail are unique. At time of registration, the password is generated like: sha1($username.$password); The problem is that user is not able to login using email. App Controller var $components = array('Auth'); public function beforeFilter(){ if(isset($this->params['prefix']) && $this->params['prefix'] == 'webadmin') { $this->Auth->userModel = 'Admin'; $this-

Is there a way to set the default date in a CakePHP date form input?

心已入冬 提交于 2019-12-21 20:27:24
问题 I have this: <?php echo $this->Form->input('Schedule.0.end_date', array( 'minYear' => date('Y'), 'maxYear' => date('Y')+5 )); ?> I would like to set the default date to something other than today. Is this possible with CakePHP's form helper? I found a post that showed how do to it with TIME - but trying something similar by setting "day", "month", "year" does nothing. 回答1: You can achieve that using the selected parameter of $this->Form->input(); . Try like this: <?php echo $this->Form->input

Assigning Layout in cakephp

╄→尐↘猪︶ㄣ 提交于 2019-12-21 20:14:49
问题 Can we define a Layout for whole controller in that particular controller?I have used before filter of the appcontroller for this purpose earlier but it doesnt solves it any more.So i need that there should be some definition of layout in controller that would apply for all the actions of that controller. Regards 回答1: use it: inside your action $this->layout = 'mylayout'; you have to create that layout in view/layout/mylayout.ctp or add this function to controller to set layout for each