0

I use the Color Field as a field in a custom module from where I create the content type programatically.

By default the available colors are defined at this hook: color_field_field_settings_form

in the color_field module.

I need to modify the list of available colors and I wanted to do at the field creation time.

At my _slider_installed_instances function I have:

EDIT: Added the settings section with no results.

        'slider_background' => array(
                'field_name' => 'slider_background',
                'type' => 'color_field_rgb',
                'label' => $t('Slider background color'),
                'widget' => array(
                        'type' => 'color_field_default_widget',
                ),
                'settings' => array(
                        'default_colors' => array(
                                'default_value' => '#AC725E,#D06B64',
                        ),
                ),
                'display' => array(
                        'default' => array(
                                'label' => $t('Slider background color'),
                                'type' => 'text'
                        )
                ),

        ),

and I wonder how to define the settings for default colors so the list will be the one defined by me at my module.

I'll appreciate any hint.

Thanks in advance.

0

Finally to achieve I move to implement in my custom module the hook hook_field_info_alter and update at this hook the $info[field]['settings']['default_colors'] list of hex color values.

I couldn't find the solution I was looking for.

0

You are using the following code:

'settings' => array(
  'default_colors' => array(
    'default_value' => '#AC725E,#D06B64',
  ),
),

The correct structure for the settings array is the following one, in your case.

'settings' => array(
  'default_colors' => '#AC725E,#D06B64',
),
  • @ShawnConn how does this not answer the question? It points out before/after of what the code should be. Is it incorrect? If so, that that needs to be pointed out in a comment and/or downvote (incorrect answers are still answers, but what the voting system is for). – mpdonadio Jul 23 '15 at 14:29
  • I added the part of the code that should be changed, but it was obvious what this answer suggested. – kiamlaluno Jul 23 '15 at 16:19
  • I am far from that code now (job change), so I can't check if it works, but it looks like it will work. Thanks. I will notice for the next. If I have the chance to recover the code I will come back to confirm it. btw, who is @ShawnConn? – manou Jul 26 '15 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.