I have a few Jquery Colorpicker fields added to node, with some label, default value, required flag, etc.
But on node edit form, fields doesn't respect my settings (label 'Color', no default value, no required)

Also on Manage Display page, I can see following error:

Notice: Undefined index: field types in field_ui_formatter_options() (line 1451 of .../modules/field_ui/field_ui.admin.inc).
Warning: Invalid argument supplied for foreach() in field_ui_formatter_options() (line 1451 of .../modules/field_ui/field_ui.admin.inc).

Comments

jaypan’s picture

Status: Active » Postponed (maintainer needs more info)

Please show me some of the code you are using. Without that I can't replicate your issue.

zakjan’s picture

I don't have any special code for this.. it is just D7 Field attached via Field UI to content type Webform.

jaypan’s picture

Even that much helps. Without some kind of information about the environment in which it is being used, it's almost impossible to debug.

chrisgross’s picture

I'm having this same problem on D7 / Zen subtheme. The picker works, but as a field, not so much. Default settings do not stick, and I get the same error in manage displays. Is it required to add that PHP code in addition to just adding a field to a content type?

jaypan’s picture

No, it's not supposed to be.

Sorry about the hassles guys. When I get a chance I'll sit down and try to replicate and fix the problem. I think I must have missed a necessary hook. There unfortunately isn't a lot of documentation on this topic yet, so it's still trial and error at the moment.

zakjan’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.75 KB

Fixed, it was easy.

zakjan’s picture

StatusFileSize
new1.4 KB
chrisgross’s picture

Is the second patch an updated version of the first? Why are there two?

zakjan’s picture

Yes, second is updated.

johnkennedy’s picture

Thanks for that #7

anton-staroverov’s picture

Thanks for the patch #7, worked for me.

But I found a nasty bug. If you enter multiple values ​​in one field, they will not display correctly. All of them will have the color of the last value. The error is in these lines: 322, 326 (function jquery_colorpicker_field_formatter_view)

My fix:

function jquery_colorpicker_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
{
	$element = array();
	foreach($items as $delta => $item)
	{
		if($display['type'] == 'jquery_colorpicker_color_display')
		{
			$element[$delta]['#markup'] = '<div id="jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '">&nbsp;</div>';
			$element[$delta]['#attached']['css'][] = array
			(
				'type' => 'inline',
				'data' => '#jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '{background-color:#' . $item['jquery_colorpicker'] . ';}',
			);
		}
		elseif($display['type'] == 'jquery_colorpicker_text_display')
		{
			$element[$delta]['#markup'] = '<div class="jquery_colorpicker_text_display"><span class="jquery_colorpicker_hash_mark">#</span>' . $item['jquery_colorpicker'] . '</div>';
		}
	}
	return $element;
}
muschpusch’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.4 KB

@zakjan: your patch was patching the jquery_colorpicker.new.module instead of jquery_colorpicker.module file. I changed that! It seems to fix the issue :) changing status

@tonystar: this is a new issue and actually the solution i was looking for. Thanks! I will attach a patch here #1149120: Multiple colored divs get same class

plopesc’s picture

Assigned: Unassigned » plopesc
Status: Reviewed & tested by the community » Closed (fixed)

Hello

Thank you very much for your help.

I tested your patch and committed your changes.

Regards