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
3333 */
3434 protected function _beforeSave ()
3535 {
36+ /** @var Mage_Core_Model_Config_Element $config */
3637 $ config = $ this ->getFieldConfig ();
3738
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+
3848 $ with_hash = true ;
3949 if (isset ($ config ->with_hash )) {
40- $ with_hash = ( bool ) $ config ->with_hash ;
50+ $ with_hash = $ config ->is ( ' with_hash ' , true ) ;
4151 }
4252
4353 if ($ with_hash ) {
Original file line number Diff line number Diff line change @@ -54,9 +54,10 @@ public function getHtmlAttributes()
5454 public function getElementHtml ()
5555 {
5656 $ id = $ this ->getHtmlId ();
57- $ with_hash = (bool ) ($ this ->original_data ['with_hash ' ] ?? 1 );
5857
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 ' ) {
6061 $ oninput = "document.getElementById(' {$ id }').value = this.value " ;
6162 $ regex = self ::VALIDATION_REGEX_WITH_HASH ;
6263 $ 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