PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 22, 2022

[FIXED] How to do Croogo Model Validation ...?

 April 22, 2022     cakephp, cakephp-2.3, croogo, php     No comments   

Issue

Am using Croogo 1.5.2 for my project. I am new to croogo System. The Croogo folder path is like this, /My_project/app/Plugin/Croogo/ Inside Plugin folder, i have created new folder named Plugin/My_folder. In that folder i have created My_controller and action add(). Also i have created the view file for add() contains the form. Now the prob am facing is, am not able to achieve model validation for my form. My_model.php contains as follow,

App::uses('AppModel', 'CroogoAppModel');
/**
 * MY_model Model
 *
 */
class MY_model extends AppModel {

/**
 * Validation rules
 *
 * @var array
 */

    public $validate = array(
        'first_name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Your custom message here',
            )
        )   
    );
}

The Model path is correct. But It is not validating the form fields.

If anybody knows the answer, help me. Thanks in advance.


Solution

In our Model file, no need to add the below line of code. App::uses('AppModel', 'CroogoAppModel'); Directly we can extend the AppModel.

And then, just we need to check with the method used in our controller action for model validation. It works depend on the cakephp version. Eg : $this->Model->validate(), $this->Model->invalidFields();

/**
 * MY_model Model
 *
 */
class MY_model extends AppModel {

/**
 * Validation rules
 *
 * @var array
 */

    public $validate = array(
        'first_name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Your custom message here',
            )
        )   
    );
}

It's working for me...



Answered By - Kavya B R
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing