Skip to content

Instantly share code, notes, and snippets.

@hadl
Last active May 12, 2020 15:47
Show Gist options
  • Save hadl/b508d12f5e3150426afb1bf93fd70033 to your computer and use it in GitHub Desktop.
Save hadl/b508d12f5e3150426afb1bf93fd70033 to your computer and use it in GitHub Desktop.
/* eslint-disable no-undef,object-shorthand,no-param-reassign */
pimcore.registerNS('pimcore.document.tags.color');
pimcore.document.tags.color = Class.create(pimcore.document.tag, {
initialize: function (id, name, options, data, inherited) {
this.id = id;
this.name = name;
this.setupWrapper();
options = this.parseOptions(options);
options.value = data || '';
options.name = id + '_editable';
this.element = new Ext.form.field.Text(options);
this.element.inputType = 'color';
this.element.render(id);
if (options.required) {
this.required = options.required;
}
},
getType: function () {
return 'color';
},
getValue: function () {
return this.element.getValue();
},
});
<?php
/**
* Color Input Editable
*/
namespace AppBundle\Model\Document\Tag;
use Pimcore\Model\Document\Tag\Input;
class Color extends Input
{
/**
* Return the type of the element
* @see TagInterface::getType
*
* @return string
*/
public function getType()
{
return 'color';
}
}
pimcore:
documents:
tags:
map:
color: AppBundle\Model\Document\Tag\Color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment