How to make file uploading as optional with validation?
The code below validates even if i didn't selected any file.
I want to check the extension only if i selected the the file.
If i am not selecting any file it should not return any validation error.
class Catalog extends AppModel{
var $name = 'Catalog';
var $validate = array...
Hello all
I am trying to implement form validation using cakephp models. Here are my code snippets...
Model
// File: /app/models/enquiry.php
class Enquiry extends AppModel {
var $name = "Enquiry";
var $useTable = false;
var $_schema = array(
"name" => array( "type" => "string", "length" => 100 ),
"ph...
can any one suggest me the best way to write the code for uploading a file?
I need to upload file and save the file name in table.
if the record saving is failed it should not upload the file.
If the uploading is failure then the record should be rollbacked.
The code should be reusable
I need to upload the file in afterSave callBack
...
I am currently trying to perform pagination using CakePHP's pagination helper.
I have a series of "Listing" rows that are returned and paginated as expected. When the user clicks on the column headings however, I'd like the sort() method to be forced to prioritise certain listings (i.e. priority listings, those with ['Listing']['priori...
I have a rather simple data model, but I have a centric entity called "item" which is associated to 7 other entities via 1-to-1 / 1-to-many relationships.
Everything works smooth. But in most actions that work with the item model, I dont need any of the associations from the item Model - so mysql ends up issuing a many unnecessary querie...
I'm attempting to create a simple 'tags' type of setup, allowing admins to 'tag' an image so it shows up in certain places. I've only started development and wanted to tackle this portion first. I literally just finished running bake, so everything at the moment is standard and I haven't touched any of the generated code.
I have three ...
Tree helper By Andy Dawson
http://bakery.cakephp.org/articles/view/tree-helper-1
//---acl_aros_controller
$aros = $this->AclAro->find('threaded');
$this->set('aros',$aros);
//--- View
echo $tree->generate($aros, array('alias'=>'alias'));
RESULT -----------------------------------------------------
Root
----|Members
...
Hi I'm setting up admin routing in CakePHP.
This is my current route:
Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages', 'action' => 'display', 'home'));
It works fine, but I don't understand what the difference between 'admin' => true, and 'prefix' => 'admin' is.
Whe...
I was just merrily working on a CakePHP site and suddenly... white screen of death. No debug information, nothing whatsoever generated by visiting the site.
Previously when this has happened there's been an error in core.php, or something else in the config folder. But the only hazardous thing I had open at the time was core.php, and ...
How do I run validation checks on a password field in CakePHP, seeing that the password is hashed before I get a chance to run any checks on it?
...
I just migrated a site to an updated version, but want to put 301 redirects in place for some of the most common entry pages of the site to their counterparts
So here's the rule I'm adding to the .htaccess:
Redirect 301 /oldhomepage.htm http://www.thesite.com/
It sort of works, but it redirects to
http://www.thesite.com/?url=oldho...
Is there an intrinsic reason why I can't, in routes.php, route a user based on the contents of a session variable? e.g.
Router::connect('/dashboard',
array('controller'=>'users','action'=>'dash',1)
);
works okay, but, replacing the 1 with $_SESSION['userid'] doesn't.
Am I missing something important about session variables here?...
Hello all
I am trying to implement form validation using cakephp models. Here are my code snippets...
Model
// File: /app/models/enquiry.php
class Enquiry extends AppModel {
var $name = "Enquiry";
var $useTable = false;
var $_schema = array(
"name" => array( "type" => "string", "length" => 100 ),
"ph...
is there any mistake in this validation???
var $validate = array(
'brand_id' => array(
'required' => array(true),
'message' => array('select a brand'),
)
);
brand_id is a select box
It show error as "message" instead of "select a brand"
if the message is not in array it shows error
Warning (2): preg_match() [function.p...
hello friends
Can any one provide me some tips to write reusable code in PHP / CakePHP
thanks in advance
...
Hello all
I was wondering what is the difference between sending a basic message and message using SMTP in cakephp
Regards
...
I am trying to implement jqgrid v3.7 in my webapplication created using cakephp v1.3.
My controller code is as follows
function admin_index()
{
// get how many rows we want to have into the grid - rowNum parameter in the grid
$limit = $this->params['url']['rows'];
// get index row - i.e. user click to sort. At first time s...
Hello,
I want to limit my db data on CakePhp. It can be limited with find command but I don't know is it possible to limit with my usage. Here is my code from posts_controller.php file:
function index() {
$this->Post->order = array('order'=>'Post.date DESC','limit'=>5);
$this->Post->recursive = 0;
$this->set('posts', ...
Hello,
I want to learn where developers here learned CakePhp. Cookbook is good at most points but not clear enough to teach I think.
Thanks,
...
Let me preface by saying this is the first live cakephp project for me.
I'm trying to move logic out of the controller to the model but the fact that compoents are not available makes this awkward.
For example, I want to send a notification email after a user registration. I've moved my email function into the model, but now have to im...