Admin: Remove missing content types from custom field type2 to avoid validation errors on submit

This commit is contained in:
nathan 2023-04-24 14:04:21 -06:00
parent 9b57b24f0e
commit 2e3784ea54

View File

@ -478,6 +478,7 @@ class admin_customfields
// Show sub-type row, and get types // Show sub-type row, and get types
if($this->manage_content_types) if($this->manage_content_types)
{ {
$content['cf_type2'] = is_array($content['cf_type2']) ? $content['cf_type2'] : explode(",", $content['cf_type2']);
if(empty($this->content_types)) if(empty($this->content_types))
{ {
$this->content_types = Api\Config::get_content_types($this->appname); $this->content_types = Api\Config::get_content_types($this->appname);
@ -491,6 +492,9 @@ class admin_customfields
{ {
$this->types2[$type] = is_array($entry) ? $entry['name'] : $entry; $this->types2[$type] = is_array($entry) ? $entry['name'] : $entry;
} }
// Make sure there are no invalid types in the value (from deleted types)
$content['cf_type2'] = array_intersect($content['cf_type2'], array_keys($this->types2));
$sel_options['cf_type2'] = $this->types2; $sel_options['cf_type2'] = $this->types2;
} }
else else