diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 3a396e365d7..768031467bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1948,14 +1948,15 @@ class ExtraFields /** * Fill array_options property of object by extrafields value (using for data sent by forms) * - * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) - * @param object $object Object - * @param string $onlykey Only some keys are filled: - * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. - * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. - * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) + * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) + * @param object $object Object + * @param string $onlykey Only some keys are filled: + * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. + * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. + * @param int $todefaultifmissing 1=Set value to the default value in database if value is mandatory and missing + * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) */ - public function setOptionalsFromPost($extralabels, &$object, $onlykey = '') + public function setOptionalsFromPost($extralabels, &$object, $onlykey = '', $todefaultifmissing = 0) { global $_POST, $langs; @@ -2015,8 +2016,10 @@ class ExtraFields || (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_'.$key] == '0') || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) { //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; + + // Field is not defined. We mark this as a problem. We may fix it later if there is a default value and $todefaultifmissing is set. $nofillrequired++; - $error_field_required[] = $langs->transnoentitiesnoconv($value); + $error_field_required[$key] = $langs->transnoentitiesnoconv($value); } } @@ -2047,12 +2050,22 @@ class ExtraFields } } + if (!empty($error_field_required[$key]) && $todefaultifmissing) { + // Value is required but we have a default value and we asked to set empty value to the default value + if (!empty($this->attributes[$object->table_element]['default']) && !is_null($this->attributes[$object->table_element]['default'][$key])) { + $value_key = $this->attributes[$object->table_element]['default'][$key]; + unset($error_field_required[$key]); + $nofillrequired--; + } + } + $object->array_options["options_".$key] = $value_key; } if ($nofillrequired) { $langs->load('errors'); - setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors'); + $this->error = $langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required); + setEventMessages($this->error, null, 'errors'); return -1; } else { return 1; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 68e76e85ca3..56aa24a8523 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -509,12 +509,14 @@ function project_admin_prepare_head() $head[$h][2] = 'attributes_task'; $h++; - $langs->load("members"); + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + $langs->load("members"); - $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php'; - $head[$h][1] = $langs->trans("BlankSubscriptionForm"); - $head[$h][2] = 'website'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php'; + $head[$h][1] = $langs->trans("BlankSubscriptionForm"); + $head[$h][2] = 'website'; + $h++; + } complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove'); diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 4bfb899cffe..36ef3a501ff 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -265,7 +265,7 @@ print '