multiple model validation cakephp 2

frenchman100

i am using the latest cakephp2. In one controller, i have multiple action.

For exemple

OrderController.php

public function save_1(){
  //check validate of model and save
}

public function save_2(){
  //check validate of model and save
}

In the model:

Order.php

public $validate = array(
    'name' => array(
        'rule'    => 'notEmpty',
        'message' => 'Please enter Name'
    )
);

In the function save_1 of my controller, i need to check the name. That work.

But in the save_2 function, i have only to check the adress.

How can i make multiple validation with only 1 model ?

Thank you for your answer and sorry for my english ..

Ritish Vermani

You can use Multivalidatable behavior in your model. Below is the link.

http://bakery.cakephp.org/articles/dardosordi/2008/07/29/multivalidatablebehavior-using-many-validation-rulesets-per-model

Thanks..!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Model Validation in CakePHP

From Dev

CakePHP validation with OR condition in Model

From Dev

Email Validation in cakephp Model

From Dev

CakePHP 2 Model relations multiple foreign Keys

From Dev

Cakephp: multiple file validation

From Dev

Form Validation in CakePHP 2

From Dev

cakephp 3 form validation for associated model data

From Dev

Yii2 validation rule in model have multiple scenarios

From Dev

MVC Model Validation Multiple View

From Dev

Saving Multiple record related to the same Model in Cakephp

From Dev

Multiple Associations to the Same Model in CakePHP 3

From Dev

Cakephp 3.0 - Multiple relations to the same model

From Dev

CakePhp Access Multiple Tables in One Custom Model

From Dev

Saving Multiple record related to the same Model in Cakephp

From Dev

CakePHP 3.X Multiple Model association

From Dev

CakePHP2 validation on field not in table

From Dev

Does CakePHP model validation not work when $useTable = false?

From Dev

Display multiple validation errors for Mongoose model

From Dev

MVC Validation from one model to multiple views

From Dev

cakephp 2 name variable in model and controller

From Dev

CakePHP 2.x Accessing Another Model

From Dev

CakePHP 3.x unique validation not working for saving multiple records

From Dev

CakePHP updating multiple rows with record ids, same model

From Dev

CakePHP updating multiple rows with record ids, same model

From Dev

Same Remote Validation for 2 different properties in a model

From Dev

Cakephp 2 Validation required even after field is not empty

From Dev

CakePHP model behaviors in Symfony2 + Doctrine2?

From Dev

CakePHP 3 - How to automatically show validation errors in view for form without model

From Dev

CakePHP 3 - How to automatically show validation errors in view for form without model

Related Related

  1. 1

    Model Validation in CakePHP

  2. 2

    CakePHP validation with OR condition in Model

  3. 3

    Email Validation in cakephp Model

  4. 4

    CakePHP 2 Model relations multiple foreign Keys

  5. 5

    Cakephp: multiple file validation

  6. 6

    Form Validation in CakePHP 2

  7. 7

    cakephp 3 form validation for associated model data

  8. 8

    Yii2 validation rule in model have multiple scenarios

  9. 9

    MVC Model Validation Multiple View

  10. 10

    Saving Multiple record related to the same Model in Cakephp

  11. 11

    Multiple Associations to the Same Model in CakePHP 3

  12. 12

    Cakephp 3.0 - Multiple relations to the same model

  13. 13

    CakePhp Access Multiple Tables in One Custom Model

  14. 14

    Saving Multiple record related to the same Model in Cakephp

  15. 15

    CakePHP 3.X Multiple Model association

  16. 16

    CakePHP2 validation on field not in table

  17. 17

    Does CakePHP model validation not work when $useTable = false?

  18. 18

    Display multiple validation errors for Mongoose model

  19. 19

    MVC Validation from one model to multiple views

  20. 20

    cakephp 2 name variable in model and controller

  21. 21

    CakePHP 2.x Accessing Another Model

  22. 22

    CakePHP 3.x unique validation not working for saving multiple records

  23. 23

    CakePHP updating multiple rows with record ids, same model

  24. 24

    CakePHP updating multiple rows with record ids, same model

  25. 25

    Same Remote Validation for 2 different properties in a model

  26. 26

    Cakephp 2 Validation required even after field is not empty

  27. 27

    CakePHP model behaviors in Symfony2 + Doctrine2?

  28. 28

    CakePHP 3 - How to automatically show validation errors in view for form without model

  29. 29

    CakePHP 3 - How to automatically show validation errors in view for form without model

HotTag

Archive