cakephp-2.0

CakePHP: posted file data not included in request->data

走远了吗. 提交于 2019-12-05 00:02:11
问题 I'm trying to upload a file to 3rd party endpoint, but I can't post the file directly from my form because the API requires an api_key which I can't expose to the end user. Therefore, my plan was to point the form to a controller/action and post the data from there. However, when I debug($this->request->data) from inside the controller, the file data is missing. The form on the view: echo $this->Form->create('Media', array('type'=>"file", 'url'=>array('controller'=>'media', 'action'=>'upload'

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

Ajax pagination with filters in cakephp

孤街浪徒 提交于 2019-12-04 19:57:38
Can anybody give a best example of ajax pagination in cakephp 2.x. This should include data filtering also. I have read cakephp manual but could not understand much. After a long search and work, i have developed a solution which is as follows: Client Side: Fist of all create a form with all filtering options. Submit the form using ajax. Use Post method to submit the form. Submit the form using serialize method. Server Side: All filter form data will be available in $this->request->data. Set PaginatorHelper options as mentioned below: $this->paginator->options(array( 'url' => $this->passedArgs

how to pull posts from wordpress to other non-wordpress site on different hosting?

巧了我就是萌 提交于 2019-12-04 17:36:50
How can I pull the posts of one blogger(written on his wordpress blog) to my site without installing the wordpress on my site? What are requirements and limitations of doing that? There are a couple ways to use wordpress as a CMS only, without actually using it as your site or to expose content for use on another site. RSS feeds as noted in another answer is good for read-only access to posts. To interact with content you'll need another solution. You can enable XML-RPC in wordpress and use a library like php xmlrpc to connect and pull post data. However, XML-RPC is limited out of the box and

CakeEmail problems on server

送分小仙女□ 提交于 2019-12-04 16:55:18
I'm using cakeEmail for simple form and on localhost it worked great, but on server(hosting) It shows me this error: CONNECTION REFUSED Error: An Internal Error Has Occurred. Stack Trace CORE/Cake/Network/Email/SmtpTransport.php line 101 → CakeSocket->connect() CORE/Cake/Network/Email/SmtpTransport.php line 61 → SmtpTransport->_connect() CORE/Cake/Network/Email/CakeEmail.php line 1124 → SmtpTransport->send(CakeEmail) APP/Controller/ProductsController.php line 26 → CakeEmail->send(string) [internal function] → ProductsController->email() CORE/Cake/Controller/Controller.php line 490 →

CakePHP 2 - Validating password fields

帅比萌擦擦* 提交于 2019-12-04 16:32:50
I have some problem with Cakephp 2 validation. I am trying to validate several fields on an Edit form. Some of them are a password and confirm password fields. I want to validate both only if they are supplied. If they are empty I dont change the password, but if the user writes over them I would like to validate if they have a minLength or the passwords matchs. Code: 'pwd' => array( 'length' => array( 'rule' => array('between', 8, 40), 'message' => 'Your password must be between 8 and 40 characters.', 'allowEmpty' => true ), ), 'pwd_repeat' => array( 'length' => array( 'rule' => array(

Cake PHP 2.4.x. AuthComponent login() always return true

喜欢而已 提交于 2019-12-04 15:41:53
Sorry for the VERY long question, but I am having problems with auth->login() and after long hours of debugging, I would like to share my findings. It may well be something stupid on my side, but bear with me... Model "Cliente" (relevant parts): <?php App::uses('AppModel', 'Model'); App::uses('BrValidation', 'Localized.Validation'); App::uses('AuthComponent', 'Controller/Component'); App::uses('SimplePasswordHasher', 'Controller/Component/Auth'); /** * Cliente Model * */ class Cliente extends AppModel { public $primaryKey = 'idcliente'; public function beforeSave($options = array()) { if

CakePHP-2.0: How can i send email from a gmail account using CakEmail and SMTP setting?

别来无恙 提交于 2019-12-04 14:01:22
问题 I'm trying to send email from a gmail account using CakEmail and SMTP settings . It would be nice if someone tell the process step by step what to do . I have added the following in app/Config/email.php=> <?php class EmailConfig { public $smtp = array( 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'username' => 'my@gmail.com', 'password' => 'secret' ); } Now how can i send email to any email account from "my@gmail.com" ? It's CakePHP-2.0 回答1: From the docs: You can configure SSL SMTP

Dynamically created datasource not being passed to associated models in CakePHP

六月ゝ 毕业季﹏ 提交于 2019-12-04 12:58:07
I have a Model - Car - the Car has several associated models, lets consider one of them which is linked with the hasMany relationship - Wheel In my CarsController, I dynamically generate a datasource using the following code - $schemaName = $this->Session->read('User.schema'); $config = ConnectionManager::getDataSource('default')->config; $config['database'] = $schemaName; ConnectionManager::create($schemaName, $config); Then I set this datasource in my Car Model using the following line of code $this->Car->setDataSource($schemaName); After this I am able to query and operate on Car, however,

CakePHP 2: new exceptions

坚强是说给别人听的谎言 提交于 2019-12-04 12:18:06
问题 I'd like to create a new exception, called SecurityException. Where should I put the code? class SecurityException extends CakeException {}; Thanks! 回答1: Create an exceptions.php file, put it on the Lib folder and fill it up with all your *Exception classes. Then include it on your application's bootstrap file. require APP . 'Lib' . DS . 'exceptions.php'; All exceptions will become available application wide. 回答2: I followed luchomolina's 2nd answer (commented on his own answer), and thought