#tree = true problem

aaron1234nz - September 12, 2008 - 22:00
Project:Colorpicker
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I've implemented colorpicker in one of my modules, however, I have recently come up against an issue where the colorpicker_textfiled and colorpicker do not link themselves together. I've narrowed the problem down to setting #tree = true on one of the form elements parents.

  $form['attributes'] = array(
      '#type' => 'markup',
      '#value' => ' ',
      '#tree' => TRUE, //the offending line
      );
  $form['attributes']['Color']['color00_colorpicker'] = array(
    '#type' => 'colorpicker',
    '#title' => t('Color 00'),
    );
  $form['attributes']['Color']['color00'] = array(
    '#type' => 'colorpicker_textfield',
    '#default_value' => ($attributes['color12'] ? $attributes['color12'] : '#A186BE'),
    '#colorpicker' => 'color00_colorpicker',
    );

When #tree is false the id of the colorpicker text field is "edit-color00", but when #tree is true, the id changes to "edit-attributes-Color-color00"

#1

aaron1234nz - September 12, 2008 - 22:15
Status:active» fixed

Don't worry, solved it.

I needed to write

  $form['attributes']['Color']['color00'] = array(
    '#type' => 'colorpicker_textfield',
    '#default_value' => ($attributes['color12'] ? $attributes['color12'] : '#A186BE'),
    '#colorpicker' => 'attributes_Color_color00_colorpicker',
    );

#2

Anonymous (not verified) - September 26, 2008 - 22:31
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.