From: Coleman Watts Date: Thu, 2 Apr 2015 00:09:50 +0000 (-0400) Subject: CRM-16214 - Set default value on option_value form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2b90b596e703c3badb730efcbbcd260433175695;p=civicrm-core.git CRM-16214 - Set default value on option_value form --- diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index cdf5ef0f7d..5818f2b1c2 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -115,17 +115,18 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { /** * Set default values for the form. - * the default values are retrieved from the database - * * * @return void */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); - if (!isset($defaults['weight']) || !$defaults['weight']) { - $fieldValues = array('option_group_id' => $this->_gid); - $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues); + // Default weight & value + $fieldValues = array('option_group_id' => $this->_gid); + foreach (array('weight', 'value') as $field) { + if (empty($defaults[$field])) { + $defaults[$field] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, $field); + } } //setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575