Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个表格,我有“卡路里”字段。我只需要接受正数。当我保存时,我添加了单位,然后我无法在模型中设置它。
这个怎么做?
创建一个自定义验证约束并使用以下 PHP 来检查数字是否为偶数:
if (filter_var($number, FILTER_VALIDATE_INT)) { // its even }