Viewing 2 reply threads
  • Author
    Posts
    • #7403
      mattkl
      Participant

      Just wanted to put this out there, in case anyone else had the same question. I wanted to use the color picker with some predefined color options. I couldn’t find anything on this site or anywhere else (but may not have searched properly). I did find a post about how to set the default palette for all color pickers (https://siteorigin.com/thread/custom-iris-picker/); but, that solution didn’t quite work. Initial colorpicker fields still showed the default options. Only when used as or in an add-more did my custom palettes show. So, not a good option; unless I have stumbled on a fixable bug.

      A little more experimentation and this is what I figured out:

      array(
          'type' => 'colorpicker'
          ,'field' => 'color-bk'
          ,'label' => 'Highlight Color'
          ,'options' => array(
              'palettes' => array('#00bbff', '#ffbb00','#aaaaaa', '#dd9933','#eeee22', '#81d742', '#ff0000')
          )
      )

      This allows you to set the default colors that are displayed as options on the bottom of the color picker. I do not claim it is the most efficient or elegant solution, if you want the same default palette across multiple colorpicker fields. But it does appear to work.

    • #7404
      jessemarco
      Participant

      Default value can be set by value also

      piklist('field', array(
          'type' => 'colorpicker'
          ,'field' => 'colorpicker'
          ,'label' => 'Choose a color'
          ,'value' => '#aee029'
          ,'description' => 'Click in the box to select a color.'
          ,'help' => 'This is help text.'
          ,'attributes' => array(
            'class' => 'text'
          )
        ));
    • #7405
      mattkl
      Participant

      Ok. Outlook ate your response and spit it out kind of wonky, and you have it marked as private here, so I cannot see it the way you intended. From what I can decode in the email, I think setting the value is what you’re proposing. That’s ok, if you only want a single default color and if you’re not using the color picker in an add-more. In add-more fields, I have not been able to get default values to work. At all. Plus, I need several default colors available for my client. So, setting the default palettes is the best solution – for me, anyway.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.