thinkphp---Auto-validation issues

Source: Internet
Author: User

This time to do a project: using thinkphp to do an automatic verification, but found that if the new time, can be automatically verified, but in the modification of the changes, you will find that the automatic validation will be invalidated.

When validating, the model is written like this:

protected $_validate Array (    array(' title ', ' Require ', ' title cannot be empty! '),    array(' title ', ' ', ' title already exists! ', 0, ' unique ', 1),    array(' name ', '/^[a-za-z]+$/', ' identity not plain English ', 1),    array(' name ', ' Require ', ' The logo cannot be empty! '),    array(' name ', ' ', ' identity already exists! ', 0, ' unique ', 1),);

This says: No problem at all. But a closer look will reveal that when adding an operation, the title verifies that the unique/name validation is English and unique. However, when modifying the operation, it will be found that he will not verify the unique. That is, when you modify it, you can change it to the same field.

To verify when adding and modifying:

protected $_validate Array (    array(' title ', ' Require ', ' title cannot be empty! '),    array(' title ', ' ', ' title already exists! ', 0, ' unique '),    array(' name ', '/^[a-za-z]+$/', ' identity not plain English '),    array(' name ', ' Require ', ' The identity cannot be empty! '),    array(' name ', ' ', ' identity already exists! ', 0, ' unique '),);

thinkphp---Auto-validation issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.