value ){ $this->value = $this->colors[0]; } $hidden = $this->htmlFactory->makeInputHidden( $this->name(), $this->value ); $title = $this->htmlFactory->makeElement('span', '  ') ->addAttr('class', 'hc-btn') ->addAttr('style', 'background-color: ' . $this->value . ';') ->addAttr('class', 'hc-inline-block') ->addAttr('class', 'hc-m1') ->addAttr('class', 'hc-px2') ->addAttr('class', 'hc-py1') ->addAttr('class', 'hc-border') ->addAttr('class', 'hc-rounded') ->addAttr('class', 'hcj-colorpicker-display') ; $options = array(); foreach( $this->colors as $color ){ $option = $this->htmlFactory->makeElement('a', '  ') ->addAttr('class', 'hc-btn') ->addAttr('style', 'background-color: ' . $color . ';') ->addAttr('class', 'hc-inline-block') ->addAttr('class', 'hc-m1') ->addAttr('class', 'hc-px2') ->addAttr('class', 'hc-py1') ->addAttr('class', 'hc-border') ->addAttr('class', 'hc-rounded') ->addAttr('data-color', $color) ->addAttr('class', 'hcj-colorpicker-selector') ; $options[] = $option; } $options = $this->htmlFactory->makeCollection( $options ); $display = $this->htmlFactory->makeCollapse( $title, $options ); $out = $this->htmlFactory->makeCollection( array($hidden, $display) ); $out = $this->htmlFactory->makeBlock( $out ) ->addAttr('class', 'hcj-colorpicker-input') ; if( strlen($this->label) ){ if( strlen($this->label) ){ $out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() ); } } return $out; } }