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

Monday, January 10, 2022

[FIXED] Conditional Validation will not allow form to submit

 January 10, 2022     cakephp-3.0     No comments   

Issue

I have the below Conditional Validation, this validation only check the cc_number when the payment_method_id is 1, so it should not validate when there is other payment_method_id being used, but problem in my view page, even if I dont select the payment method, the form will not submit to the controller, unless the cc_number is filled, is there anyway to disable this cc_number check ? thank you

$validator->creditCard ( 'cc_number', [ 'mc','visa' ], __ ( 'invalid card number' ), function ($context)
        {
            if ($context ['data'] ['payment_method_id'] == 1)               
             return true;
        } );

Solution

sorry for wasting space in this area, i just code cakephp3.5 recently, seems that this problem can be easily solve by putting ,'novalidate' => true at the $this->Form->create method



Answered By - cakephp_dev1
  • 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