Phpcms only the judgment value so treatment in non empty value

Custom fields I added, the only value judgment. But when I do not want to fill in the fields, he also suggested that repeated. So I think there is no way to make his judgment, only in the non null value is only value judgment?

After a toss about, find the possible code as follows

if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage($name.L('the_value_must_not_repeat'));

Comment out this line, not only the value judgment, the question is how to let him only unique values in the non null value judgement, want to understand PHP: do me a favor

Started by Wilbur at October 30, 2016 - 3:16 AM

Non empty? ! empty front plus if.?

Posted by Joy at November 14, 2016 - 3:23 AM

To judge the custom field value is non empty, the key question is do not know how to write, I try to write
if($this->fields[$field]!=""){
if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage($name.L('the_value_must_not_repeat'));
}
Fail, do not know PHP, do not know how to judge the field value is not empty

Posted by Wilbur at November 23, 2016 - 3:31 AM

if(!empty($this->fields[$field])){
....
}

Posted by May at November 28, 2016 - 4:01 AM

Empty can determine the non null if empty returns true if false
"" Return true
0 return true
"0" Return true
False returns true
NULL returns true
array() Returns a true array is empty
var $VaR is not to assign values to variables return true
And the object does not have any attribute will be considered null return true

Posted by Katherleen at December 06, 2016 - 4:16 AM

Don't use this method, may be judged field non null field value instead of $this-> fields[$field]

Posted by Wilbur at December 08, 2016 - 4:57 AM

This is a PHPcms program, bitter master doubts

Posted by Wilbur at December 20, 2016 - 5:20 AM

Waiting for master answer

Posted by Wilbur at January 03, 2017 - 5:48 AM