How to add a color picker in magento 2.1.7 system config?Magento 2.1.6 No confirmation emails sent from...

Was it really inappropriate to write a pull request for the company I interviewed with?

Paper published similar to PhD thesis

Is the differential, dp, exact or not?

Why would /etc/passwd be used every time someone executes `ls -l` command?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

How does a sound wave propagate?

Create chunks from an array

Will the concrete slab in a partially heated shed conduct a lot of heat to the unconditioned area?

Do I need a return ticket to Canada if I'm a Japanese National?

Is there a logarithm base for which the logarithm becomes an identity function?

Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?

Why restrict private health insurance?

How to distinguish easily different soldier of ww2?

Is this Paypal Github SDK reference really a dangerous site?

The (Easy) Road to Code

If nine coins are tossed, what is the probability that the number of heads is even?

Was this cameo in Captain Marvel computer generated?

How do you make a gun that shoots melee weapons and/or swords?

What does it take to become a wilderness skills guide as a business?

Exempt portion of equation line from aligning?

Who has more? Ireland or Iceland?

What is the oldest European royal house?

Can I challenge the interviewer to give me a proper technical feedback?

Having the player face themselves after the mid-game



How to add a color picker in magento 2.1.7 system config?


Magento 2.1.6 No confirmation emails sent from frontendMagento 2: How to Reauthorize Paypal payment & store all informationMagento 2.1.6 Product Grid page count and record count issue when programmatically adding filter using different methodsCannot correct php.ini error in Magento 2.1.6Cannot install sample dataHow to create a repeater field (like Minsaleqty, Regexceptions) inside admin form in Magento 2?How to print different tax rates in magento 2.1.6Magento 2.1.6 to 2.1.7 Upgrade Issues Or Latest versionMagento 2 - How to display the quantity of each product in cart under the add to cart button in the product tile













1















I am trying to add a color picker in magento 2.1.7 using below link but it's not going to work anyone tell me that how to add color picker in magento 2.1.7



https://webkul.com/blog/add-color-picker-magento2-system-config/










share|improve this question





























    1















    I am trying to add a color picker in magento 2.1.7 using below link but it's not going to work anyone tell me that how to add color picker in magento 2.1.7



    https://webkul.com/blog/add-color-picker-magento2-system-config/










    share|improve this question



























      1












      1








      1








      I am trying to add a color picker in magento 2.1.7 using below link but it's not going to work anyone tell me that how to add color picker in magento 2.1.7



      https://webkul.com/blog/add-color-picker-magento2-system-config/










      share|improve this question
















      I am trying to add a color picker in magento 2.1.7 using below link but it's not going to work anyone tell me that how to add color picker in magento 2.1.7



      https://webkul.com/blog/add-color-picker-magento2-system-config/







      magento2.1.6






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 23 '17 at 12:44









      Teja Bhagavan Kollepara

      2,98641947




      2,98641947










      asked Aug 23 '17 at 9:57









      Sanjay GohilSanjay Gohil

      417113




      417113






















          1 Answer
          1






          active

          oldest

          votes


















          3














          Add JavaScript color picker library in your layout :



          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
          <head>
          <css src="jquery/colorpicker/css/colorpicker.css"/>
          </head>
          </page>


          Create system.xml



          <config ...>
          <system>
          ...
          <section>
          ...
          <group id="my_color_group" ...>
          <field id="my_color_option" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Background Color</label>
          <comment><![CDATA[Background color]]></comment>
          <frontend_model>abcColorBlockColor</frontend_model> <!-- Our block for attaching color picker to text box -->
          </field>
          </group>
          </section>
          </system>
          </config>


          Create the block file:



          <?php
          namespace abcColorBlock;

          class Color extends MagentoConfigBlockSystemConfigFormField {
          public function __construct(
          MagentoBackendBlockTemplateContext $context, array $data = []
          ) {
          parent::__construct($context, $data);
          }

          protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element) {
          $html = $element->getElementHtml();
          $value = $element->getData('value');

          $html .= '<script type="text/javascript">
          require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
          $(document).ready(function () {
          var $elementId = $("#' . $element->getHtmlId() . '");
          $elementId.css("backgroundColor", "'. $value .'");

          $elementId.ColorPicker({
          color: "'. $value .'",
          onChange: function (hsb, hex, rgb) {
          $elementId.css("backgroundColor", "#" + hex).val("#" + hex);
          }
          });
          });
          });
          </script>';
          return $html;
          }

          }





          share|improve this answer





















          • 1





            There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

            – Sanjay Gohil
            Aug 23 '17 at 13:26













          • ok sir... Happy to helping :)

            – Rohan Hapani
            Aug 23 '17 at 13:46











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f190249%2fhow-to-add-a-color-picker-in-magento-2-1-7-system-config%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Add JavaScript color picker library in your layout :



          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
          <head>
          <css src="jquery/colorpicker/css/colorpicker.css"/>
          </head>
          </page>


          Create system.xml



          <config ...>
          <system>
          ...
          <section>
          ...
          <group id="my_color_group" ...>
          <field id="my_color_option" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Background Color</label>
          <comment><![CDATA[Background color]]></comment>
          <frontend_model>abcColorBlockColor</frontend_model> <!-- Our block for attaching color picker to text box -->
          </field>
          </group>
          </section>
          </system>
          </config>


          Create the block file:



          <?php
          namespace abcColorBlock;

          class Color extends MagentoConfigBlockSystemConfigFormField {
          public function __construct(
          MagentoBackendBlockTemplateContext $context, array $data = []
          ) {
          parent::__construct($context, $data);
          }

          protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element) {
          $html = $element->getElementHtml();
          $value = $element->getData('value');

          $html .= '<script type="text/javascript">
          require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
          $(document).ready(function () {
          var $elementId = $("#' . $element->getHtmlId() . '");
          $elementId.css("backgroundColor", "'. $value .'");

          $elementId.ColorPicker({
          color: "'. $value .'",
          onChange: function (hsb, hex, rgb) {
          $elementId.css("backgroundColor", "#" + hex).val("#" + hex);
          }
          });
          });
          });
          </script>';
          return $html;
          }

          }





          share|improve this answer





















          • 1





            There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

            – Sanjay Gohil
            Aug 23 '17 at 13:26













          • ok sir... Happy to helping :)

            – Rohan Hapani
            Aug 23 '17 at 13:46
















          3














          Add JavaScript color picker library in your layout :



          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
          <head>
          <css src="jquery/colorpicker/css/colorpicker.css"/>
          </head>
          </page>


          Create system.xml



          <config ...>
          <system>
          ...
          <section>
          ...
          <group id="my_color_group" ...>
          <field id="my_color_option" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Background Color</label>
          <comment><![CDATA[Background color]]></comment>
          <frontend_model>abcColorBlockColor</frontend_model> <!-- Our block for attaching color picker to text box -->
          </field>
          </group>
          </section>
          </system>
          </config>


          Create the block file:



          <?php
          namespace abcColorBlock;

          class Color extends MagentoConfigBlockSystemConfigFormField {
          public function __construct(
          MagentoBackendBlockTemplateContext $context, array $data = []
          ) {
          parent::__construct($context, $data);
          }

          protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element) {
          $html = $element->getElementHtml();
          $value = $element->getData('value');

          $html .= '<script type="text/javascript">
          require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
          $(document).ready(function () {
          var $elementId = $("#' . $element->getHtmlId() . '");
          $elementId.css("backgroundColor", "'. $value .'");

          $elementId.ColorPicker({
          color: "'. $value .'",
          onChange: function (hsb, hex, rgb) {
          $elementId.css("backgroundColor", "#" + hex).val("#" + hex);
          }
          });
          });
          });
          </script>';
          return $html;
          }

          }





          share|improve this answer





















          • 1





            There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

            – Sanjay Gohil
            Aug 23 '17 at 13:26













          • ok sir... Happy to helping :)

            – Rohan Hapani
            Aug 23 '17 at 13:46














          3












          3








          3







          Add JavaScript color picker library in your layout :



          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
          <head>
          <css src="jquery/colorpicker/css/colorpicker.css"/>
          </head>
          </page>


          Create system.xml



          <config ...>
          <system>
          ...
          <section>
          ...
          <group id="my_color_group" ...>
          <field id="my_color_option" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Background Color</label>
          <comment><![CDATA[Background color]]></comment>
          <frontend_model>abcColorBlockColor</frontend_model> <!-- Our block for attaching color picker to text box -->
          </field>
          </group>
          </section>
          </system>
          </config>


          Create the block file:



          <?php
          namespace abcColorBlock;

          class Color extends MagentoConfigBlockSystemConfigFormField {
          public function __construct(
          MagentoBackendBlockTemplateContext $context, array $data = []
          ) {
          parent::__construct($context, $data);
          }

          protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element) {
          $html = $element->getElementHtml();
          $value = $element->getData('value');

          $html .= '<script type="text/javascript">
          require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
          $(document).ready(function () {
          var $elementId = $("#' . $element->getHtmlId() . '");
          $elementId.css("backgroundColor", "'. $value .'");

          $elementId.ColorPicker({
          color: "'. $value .'",
          onChange: function (hsb, hex, rgb) {
          $elementId.css("backgroundColor", "#" + hex).val("#" + hex);
          }
          });
          });
          });
          </script>';
          return $html;
          }

          }





          share|improve this answer















          Add JavaScript color picker library in your layout :



          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
          <head>
          <css src="jquery/colorpicker/css/colorpicker.css"/>
          </head>
          </page>


          Create system.xml



          <config ...>
          <system>
          ...
          <section>
          ...
          <group id="my_color_group" ...>
          <field id="my_color_option" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Background Color</label>
          <comment><![CDATA[Background color]]></comment>
          <frontend_model>abcColorBlockColor</frontend_model> <!-- Our block for attaching color picker to text box -->
          </field>
          </group>
          </section>
          </system>
          </config>


          Create the block file:



          <?php
          namespace abcColorBlock;

          class Color extends MagentoConfigBlockSystemConfigFormField {
          public function __construct(
          MagentoBackendBlockTemplateContext $context, array $data = []
          ) {
          parent::__construct($context, $data);
          }

          protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element) {
          $html = $element->getElementHtml();
          $value = $element->getData('value');

          $html .= '<script type="text/javascript">
          require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
          $(document).ready(function () {
          var $elementId = $("#' . $element->getHtmlId() . '");
          $elementId.css("backgroundColor", "'. $value .'");

          $elementId.ColorPicker({
          color: "'. $value .'",
          onChange: function (hsb, hex, rgb) {
          $elementId.css("backgroundColor", "#" + hex).val("#" + hex);
          }
          });
          });
          });
          </script>';
          return $html;
          }

          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 mins ago

























          answered Aug 23 '17 at 11:10









          Rohan HapaniRohan Hapani

          6,45331764




          6,45331764








          • 1





            There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

            – Sanjay Gohil
            Aug 23 '17 at 13:26













          • ok sir... Happy to helping :)

            – Rohan Hapani
            Aug 23 '17 at 13:46














          • 1





            There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

            – Sanjay Gohil
            Aug 23 '17 at 13:26













          • ok sir... Happy to helping :)

            – Rohan Hapani
            Aug 23 '17 at 13:46








          1




          1





          There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

          – Sanjay Gohil
          Aug 23 '17 at 13:26







          There is no need to add link src="jquery/colorpicker/js/colorpicker.js"/> in layout file...! @Rohan Hapani Thanks...!

          – Sanjay Gohil
          Aug 23 '17 at 13:26















          ok sir... Happy to helping :)

          – Rohan Hapani
          Aug 23 '17 at 13:46





          ok sir... Happy to helping :)

          – Rohan Hapani
          Aug 23 '17 at 13:46


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f190249%2fhow-to-add-a-color-picker-in-magento-2-1-7-system-config%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

          How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

          夢乃愛華...