2828class Varien_Data_Form_Element_Color extends Varien_Data_Form_Element_Abstract
2929{
3030 /**
31- * Varien_Data_Form_Element_Text constructor.
3231 * @param array $attributes
3332 */
3433 public function __construct ($ attributes = [])
@@ -39,19 +38,32 @@ public function __construct($attributes = [])
3938 }
4039
4140 /**
42- * @return string
41+ * @return array
4342 */
44- public function getHtml ()
43+ public function getHtmlAttributes ()
4544 {
46- $ this ->addClass ('input-text ' );
47- return parent ::getHtml ();
45+ return ['type ' , 'title ' , 'class ' , 'style ' , 'disabled ' , 'readonly ' , 'tabindex ' ];
4846 }
4947
5048 /**
51- * @return array
49+ * @return string
5250 */
53- public function getHtmlAttributes ()
51+ public function getElementHtml ()
5452 {
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 ;
5668 }
5769}
0 commit comments