From ed9f079fda1d0f5823625b84ce042efeabc57477 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 3 Jan 2012 14:46:06 +0000 Subject: [PATCH] * API/customfields: fix for Stylite Ticket#2629 ->Mandatory custom field not saved<- fix for customfields (if mandatory) where not saved on first attempt, after failed formvalidation. --- etemplate/inc/class.link_widget.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php index 4dcbd2e133..467e33f4ad 100644 --- a/etemplate/inc/class.link_widget.inc.php +++ b/etemplate/inc/class.link_widget.inc.php @@ -531,15 +531,19 @@ class link_widget switch($extension_data['type']) { case 'link-entry': + //error_log(__METHOD__.__LINE__.array2string(array('data'=>$value,'value in'=>$value_in,'extension_data'=>$extension_data,'source'=>function_backtrace()))); if (!$value_in['id'] && $extension_data['needed']) { $tmpl->set_validation_error($name,lang('Field must not be empty !!!'),''); return true; } - if (is_array($extension_data['default'])) + // beware: default may be something like Array([link_type] => [query] => [id] => ) so take care for id, in case it is empty AND needed + if (is_array($extension_data['default']) && !empty($extension_data['default'])) { $value = $extension_data['default']; $value['current'] = $extension_data['app'] ? $value_in['id'] : $value_in['app'].':'.$value_in['id']; + // we take care for id, in case it is empty AND needed + if(empty($value['id']) && $extension_data['needed']) $value['id'] = $value['current']; } else {