Commit b39a55c3 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Colour form option not saving properly (Bug #1305275)"

parents f8ba4271 f3e612a5
......@@ -34,7 +34,7 @@ $string['element.files.addattachment'] = 'Add attachment';
$string['element.select.other'] = 'Other';
$string['element.color.custom'] = 'Customise';
$string['element.color.transparent'] = 'Transparent or ';
$string['rule.before.before'] = 'This cannot be after the field "%s"';
......
......@@ -34,14 +34,14 @@ function pieform_element_color(Pieform $form, $element) {
var {$baseid}_oldval = '';
function {$baseid}_toggle(x) {
if ( x.checked ) {
$('{$baseid}').value = {$baseid}_oldval;
$('{$baseid}').disabled = false;
}
else {
{$baseid}_oldval = $('{$baseid}').value;
$('{$baseid}').value = '';
$('{$baseid}').disabled = true;
}
else {
$('{$baseid}').value = {$baseid}_oldval;
$('{$baseid}').disabled = false;
}
}
</script>
EOF;
......@@ -52,18 +52,18 @@ EOF;
}
$optional .= ' <input type="checkbox" '
. (isset($element['defaultvalue']) && $element['defaultvalue'] == 'transparent' ? '' : 'checked="checked" ')
. (isset($element['defaultvalue']) && $element['defaultvalue'] == 'transparent' ? 'checked="checked" ' : '')
. 'name="' . $name . '_optional" id="' . $baseid . '_optional" onchange="' . $baseid . '_toggle(this)" '
. 'tabindex="' . Pieform::hsc($element['tabindex']) . '">';
$optional .= ' <label for="' . $baseid . '_optional">'
. $title . $form->i18n('element', 'color', 'custom', $element) . '</label> ';
. $title . $form->i18n('element', 'color', 'transparent', $element) . '</label> ';
$result .= $optional;
}
// Color Picker (Chooser)
$result .= '<input type="text" name="' . $name . '_color" id="' . $baseid . '"'
. ($transparent && !isset($element['defaultvalue']) ? ' disabled="disabled"' : '')
. ($transparent && (!isset($element['defaultvalue']) || $element['defaultvalue'] == 'transparent') ? ' disabled="disabled"' : '')
. ($transparent ? ' class="color {hash:true,required:false}"' : ' class="color {hash:true}"')
. ' value="' . ($value == 'transparent' ? '' : $value) . '">';
......@@ -80,7 +80,7 @@ EOF;
function pieform_element_color_get_value(Pieform $form, $element) {
$name = $element['name'];
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
if ($form->is_submitted() && isset($global[$name . '_color']) && isset($global[$name . '_optional'])) {
if ($form->is_submitted() && isset($global[$name . '_color']) && !isset($global[$name . '_optional'])) {
$color = $global[$name . '_color'];
// Whitelist for a 6-digit hex color
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment