colymba / silverstripe-colorfield

SilverStripe Color picker and DBField field with attitude.
4 stars 10 forks source link

Multiple instances of colorfield #14

Closed DrMartinGonzo closed 7 years ago

DrMartinGonzo commented 7 years ago

Colorfields used to be updated all at once

colymba commented 7 years ago

hey @DrMartinGonzo, di you have an example when this was a problem? Am trying to reproduce the error...

DrMartinGonzo commented 7 years ago

Sorry, here's a minimal version of the code for a DataObject where I had the problem. I just tested it, both instances of ColorField will update at the same time. Silverstripe version is 3.5.0

public function getCMSFields() {
  $tabset = new Tabset(
    'Root',
  new Tab(
    'TK',
    ColorField::create('BgColor', 'Couleur de fond', null, array('opacity' => false)),
    ColorField::create('TKBgColor', 'Couleur derrière le TK', null, array('opacity' => true))
  )
  );

  $fields = FieldList::create(
    $tabset
  );

  return $fields;
}
colymba commented 7 years ago

@DrMartinGonzo I cannot reproduce the error. I have 4 colorField on the same page and they all work fine and independently.

Could another module cause the error?

DrMartinGonzo commented 7 years ago

It seems "something" adds 'field' as an extra class in TabSet.ss And thus var $parent = this.parents('.field'); also returns the whole tab. I will investigate. Will come back with any results.

DrMartinGonzo commented 7 years ago

What is your Silverstripe version ? I just tried it on 3.2.1, and I'm not seeing the problem. Here's why : Tabset.php on line 111 calls $this->extraClass()on CompositeField class. In 3.2.1, there's only function extraClasses so nothing happens. In 3.5.0, function extraClass exists in CompositeField and this is the one that adds the field class to the TabSet.

I don't know if it's intended behavior or not. Sorry for any bad english and lack of programming knowledge. I hope my explanation is clear enough.

colymba commented 7 years ago

I guess the selector could be more specific and parents might not be the best choice. I'll merge this asap...

colymba commented 7 years ago

Merged here ecba6241721281f299444af99acc78daf638dd72