Some interesting findings from web-dev land…
If you get this error:
1Warning: Warning (2): preg_match() [<a href=’function.preg-match’>function.preg-match</a>]: Delimiter must not be alphanumeric or backslash in [/var/www/vhosts/h2oservices.com/httpdocs/cake/libs/model/model.php, line 2611]
When trying to use a custom validation rule, make sure the method visibility is set to public.
So this should work:
123public function myCustomValidateRule(){
// Custom validation code
}
It seems protected visibility works on some versions of [...]
It can’t be done using the normal Ternary operator but you can emulate it with:
12345678910111213// So instead of:
$str = <<<HTML
{$a ? 1 : 2}
HTML;
// You can do:
$values = array(’1′, ‘2′);
$str = <<<HTML
{$values[$a]}
HTML;
If you have fields that don’t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.
In this example I’m ignoring the security_code (captcha) field, [...]
You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.
In this example I’m saving Users that HABTM Videos. The users_videos join table has an order column.
Firstly add the ‘with’ parameter to the join, you can add the ‘order’ parameter too [...]
I’m in the situation where most of my CMS components are extensible CakePHP plugs.
I’ve just started to use the CakeDC migrations plugin (been meaning to for a long time as I always loved Rails migrations).
I had previously automated the insertion of plugin ACO node records using a Bash script that chugged through a stack [...]
I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.
https://bugs.webkit.org/show_bug.cgi?id=5760
I added this to the virtual host declaration in my Apache config file to fix it:
123456<VirtualHost x.x.x.x:x>
# Prevent Safari from hanging on uploads
BrowserMatch Safari nokeepalive
</VirtualHost>
If you’re trying to use the CakePHP Media plugin with 1.3 (I’m running RC3) and you get this error when deleting an attachment:
1Call to undefined method Folder::ls() in /path_to_app/app/plugins/media/models/behaviors/media.php on line 277
ls() has been deprecated in favour of read(), change line 277 of /path_to_app/app/plugins/media/models/behaviors/media.php to:
1list($versions, ) = $Folder->read();
All should work fine thereafter ;]
I wasn’t having much luck with the example given in the CakePHP book for a Has and Belongs To Many relationship with a single option select menu in the view.
Anyway overriding the element type does the trick:
1<?php echo $form->input(’ResellerField’, array(’multiple’ => false)) ?>
Quick refresher for my own records. CakePHP ACL component console commands:
1234567891011121314151617181920212223# View ACO tree
cake acl view aco
# Create root ACO container – in this instance site
cake acl create aco root site
# Create ACO controller node – in this instance the products controller
cake acl create aco site Products
# Create ACO controller action node – in [...]
This is quite handy if you’re working in a team and you don’t want the designer/client poking about in the controllers to set page titles. You can set them in the view using this code:
UPDATE thanks for bringing the v1.3 change to my attention JT.
12345v1.3
<? $this->viewVars[’title_for_layout’] = ‘My page title’ ?>
v1.2
<? $this->pageTitle = ‘My page [...]