Not sure what is going wrong here but I am sure it is simple.
The token [node:field_report_store_name]
("Text field" token) doesn't handle special characters which [node:field-report-store-name]
("Field 'field_report_store_name' token) takes care of. This token, however, works alone without PHP, but when I try to use it in a PHP pattern, I get an Unexpected Error upon updating the automatic node title.
The below works without error, but special characters such as apostrophes display as "'
":
$storename = '[node:field_report_store_name]';
$city = '[node:field-report-zip:locality]';
$state = '[node:field-report-zip:administrative-area]';
if(empty($storename)) {
return $city.", ".$state;
} else {
return $storename." in ".$city.", ".$state;
}
The below is the exact same code but with the token that handles the special characters, and produces an Unexpected Error:
$storename = '[node:field-report-store-name]';
$city = '[node:field-report-zip:locality]';
$state = '[node:field-report-zip:administrative-area]';
if(empty($storename)) {
return $city.", ".$state;
} else {
return $storename." in ".$city.", ".$state;
}
The settings are set correctly:
The error as appears in the dblog is:
"ParseError: syntax error, unexpected 's' (T_STRING) in auto_entitylabel_eval() (line 2 of /sites/all/modules/auto_entitylabel/auto_entitylabel.module(447) : eval()'d code)."
Here is the version of the auto_entitylabel.module file: https://git.drupalcode.org/project/auto_entitylabel/-/blob/7.x-1.4/auto_entitylabel.module
The function it hangs up on is:
/**
* Evaluates php code and passes $entity and $language to it.
*/
function auto_entitylabel_eval($code, $entity, $language = LANGUAGE_NONE) {
ob_start();
// @codingStandardsIgnoreLine
print eval('?>' . $code);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
What am I doing wrong here?