mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge remote-tracking branch 'rxu/ticket/9831' into develop-olympus
* rxu/ticket/9831: [ticket/9831] Fix saving unchecked checkbox field value [ticket/9831] Correctly store checkbox default value for boolean CPF.
This commit is contained in:
commit
bd1fb91dd2
2 changed files with 33 additions and 6 deletions
|
@ -504,11 +504,34 @@ class acp_profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
|
else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
|
||||||
{
|
{
|
||||||
// Get the number of options if this key is 'field_maxlen'
|
// 'field_length' == 1 defines radio buttons. Possible values are 1 or 2 only.
|
||||||
$var = request_var('field_default_value', 0);
|
// 'field_length' == 2 defines checkbox. Possible values are 0 or 1 only.
|
||||||
}*/
|
// If we switch the type on step 2, we have to adjust field value.
|
||||||
|
// 1 is a common value for the checkbox and radio buttons.
|
||||||
|
|
||||||
|
// Adjust unchecked checkbox value.
|
||||||
|
// If we return or save settings from 2nd/3rd page
|
||||||
|
// and the checkbox is unchecked, set the value to 0.
|
||||||
|
if (isset($_REQUEST['step']) && !isset($_REQUEST[$key]))
|
||||||
|
{
|
||||||
|
$var = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we switch to the checkbox type but former radio buttons value was 2,
|
||||||
|
// which is not the case for the checkbox, set it to 0 (unchecked).
|
||||||
|
if ($cp->vars['field_length'] == 2 && $var == 2)
|
||||||
|
{
|
||||||
|
$var = 0;
|
||||||
|
}
|
||||||
|
// If we switch to the radio buttons but the former checkbox value was 0,
|
||||||
|
// which is not the case for the radio buttons, set it to 0.
|
||||||
|
else if ($cp->vars['field_length'] == 1 && $var == 0)
|
||||||
|
{
|
||||||
|
$var = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ($field_type == FIELD_INT && $key == 'field_default_value')
|
else if ($field_type == FIELD_INT && $key == 'field_default_value')
|
||||||
{
|
{
|
||||||
// Permit an empty string
|
// Permit an empty string
|
||||||
|
@ -676,6 +699,10 @@ class acp_profile
|
||||||
{
|
{
|
||||||
$_new_key_ary[$key] = utf8_normalize_nfc(request_var($key, array(array('')), true));
|
$_new_key_ary[$key] = utf8_normalize_nfc(request_var($key, array(array('')), true));
|
||||||
}
|
}
|
||||||
|
else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
|
||||||
|
{
|
||||||
|
$_new_key_ary[$key] = request_var($key, $cp->vars[$key]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!isset($_REQUEST[$key]))
|
if (!isset($_REQUEST[$key]))
|
||||||
|
|
|
@ -630,10 +630,10 @@ class custom_profile
|
||||||
|
|
||||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||||
$user_ident = $profile_row['field_ident'];
|
$user_ident = $profile_row['field_ident'];
|
||||||
// checkbox - only testing for isset
|
// checkbox - set the value to "true" if it has been set to 1
|
||||||
if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
|
if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
|
||||||
{
|
{
|
||||||
$value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
|
$value = (isset($_REQUEST[$profile_row['field_ident']]) && request_var($profile_row['field_ident'], $default_value) == 1) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
|
||||||
}
|
}
|
||||||
else if ($profile_row['field_type'] == FIELD_INT)
|
else if ($profile_row['field_type'] == FIELD_INT)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue