File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
app/code/core/Mage/Adminhtml/Model/System/Config/Backend
lib/Varien/Data/Form/Element Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,21 @@ class Mage_Adminhtml_Model_System_Config_Backend_Color extends Mage_Core_Model_C
33
33
*/
34
34
protected function _beforeSave ()
35
35
{
36
+ /** @var Mage_Core_Model_Config_Element $config */
36
37
$ config = $ this ->getFieldConfig ();
37
38
39
+ $ validate = [];
40
+ if (isset ($ config ->validate )) {
41
+ $ validate = array_map ('trim ' , explode (' ' , $ config ->validate ));
42
+ }
43
+
44
+ if (!(string )$ this ->getValue () && !in_array ('required-entry ' , $ validate )) {
45
+ return $ this ;
46
+ }
47
+
38
48
$ with_hash = true ;
39
49
if (isset ($ config ->with_hash )) {
40
- $ with_hash = ( bool ) $ config ->with_hash ;
50
+ $ with_hash = $ config ->is ( ' with_hash ' , true ) ;
41
51
}
42
52
43
53
if ($ with_hash ) {
Original file line number Diff line number Diff line change @@ -54,9 +54,10 @@ public function getHtmlAttributes()
54
54
public function getElementHtml ()
55
55
{
56
56
$ id = $ this ->getHtmlId ();
57
- $ with_hash = (bool ) ($ this ->original_data ['with_hash ' ] ?? 1 );
58
57
59
- if ($ with_hash ) {
58
+ $ with_hash = strtolower ((string ) ($ this ->original_data ['with_hash ' ] ?? 1 ));
59
+
60
+ if (!empty ($ with_hash ) && $ with_hash !== 'false ' && $ with_hash !== 'off ' ) {
60
61
$ oninput = "document.getElementById(' {$ id }').value = this.value " ;
61
62
$ regex = self ::VALIDATION_REGEX_WITH_HASH ;
62
63
$ this ->setOninput ("document.getElementById(' {$ id }:html5').value = {$ regex }.test(this.value) ? this.value : '#000000' " );
You can’t perform that action at this time.
0 commit comments