28
28
class Varien_Data_Form_Element_Color extends Varien_Data_Form_Element_Abstract
29
29
{
30
30
/**
31
- * Varien_Data_Form_Element_Text constructor.
32
31
* @param array $attributes
33
32
*/
34
33
public function __construct ($ attributes = [])
@@ -39,19 +38,32 @@ public function __construct($attributes = [])
39
38
}
40
39
41
40
/**
42
- * @return string
41
+ * @return array
43
42
*/
44
- public function getHtml ()
43
+ public function getHtmlAttributes ()
45
44
{
46
- $ this ->addClass ('input-text ' );
47
- return parent ::getHtml ();
45
+ return ['type ' , 'title ' , 'class ' , 'style ' , 'disabled ' , 'readonly ' , 'tabindex ' ];
48
46
}
49
47
50
48
/**
51
- * @return array
49
+ * @return string
52
50
*/
53
- public function getHtmlAttributes ()
51
+ public function getElementHtml ()
54
52
{
55
- return ['type ' , 'title ' , 'class ' , 'style ' , 'onclick ' , 'onchange ' , 'onkeyup ' , 'disabled ' , 'readonly ' , 'tabindex ' ];
53
+ $ id = $ this ->getHtmlId ();
54
+ $ valueWithoutHash = ltrim ($ this ->getEscapedValue (), '# ' );
55
+ $ with_hash = (bool ) ($ this ->original_data ['with_hash ' ] ?? 1 );
56
+
57
+ $ onchange = "document.getElementById(' {$ id }').value=this.value " ;
58
+ if (!$ with_hash ) {
59
+ $ onchange .= '.substring(1) ' ;
60
+ }
61
+
62
+ $ html = '<input id=" ' . $ id . '" type="hidden" name=" ' . $ this ->getName ()
63
+ . '" value=" ' . $ valueWithoutHash . '" ' . '/> ' . "\n" ;
64
+ $ html .= '<input value="# ' . $ valueWithoutHash . '" ' . $ this ->serialize ($ this ->getHtmlAttributes ())
65
+ . 'onchange=" ' . $ onchange . '" ' . '/> ' . "\n" ;
66
+ $ html .= $ this ->getAfterElementHtml ();
67
+ return $ html ;
56
68
}
57
69
}
0 commit comments