Ticket #1403 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 month ago

Make addFieldToTab() ignore duplicates

Reported by: freeyland Assigned to: sminnee
Type: enhancement Priority: blocker
Milestone: 2.2.3* Component: Sapphire Framework
Version: Severity: medium effort / impact
Keywords: Cc: ischommer, sminnee
Due date: Hours:

Description (last modified by sminnee) (diff)

In order to support multiple roles including the same field - e.g., Country - addFieldToTab() should ignore requests to add a field that already exists in the field, if the field is a data field.


Country in E-commerce and forum module for member

've installed silverstripe.2.1.DailyBuild?.2007-08-01 and I get following error when clicking to edit a user account in the security admin part:

ERROR:Error 256: collateDataFields() I noticed that a field called 'Country' appears twice. At l28 in C:\xampp\htdocs\projects\AJAX\silverstripe-v2.0\sapphire\forms\FieldSet?.php user_error(collateDataFields() I noticed that a field called 'Country' appears twice.,256) line 28 of FieldSet?.php FieldSet?->collateDataFields(Array) line 17 of FieldSet?.php FieldSet?->dataFields() line 421 of Form.php Form->loadDataFrom(Member) line 176 of MemberTableField?.php MemberTableField?->DetailForm?() line of call_user_func_array(Array,Array) line 376 of ViewableData?.php ViewableData?->XML_val(DetailForm?1) line 19 of .cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField?_popup.ss include(C:\WINDOWS\Temp\silverstripe-cache\.cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField?_popup.ss) line 190 of SSViewer.php SSViewer->process(MemberTableField?) line 720 of ViewableData?.php ViewableData?->renderWith(ComplexTableField?_popup) line 349 of ComplexTableField?.php ComplexTableField?->edit() line 523 of Form.php Form->callfieldmethod(Array,Form) line 134 of Controller.php Controller->run(Array) line 48 of Director.php Director::direct(/admin/security/index/1) line 101 of main.php

I removed the forum module and now the problem is solved. SO probably there is a conflict between e-commerce and forum module. I checked in the member table and now 1 of the two country columns is removed.

Attachments

fieldsetchanges.diff (19.5 kB) - added by sharvey 3 months ago.
Patch with current work so far (including a test)

Change History

Changed 10 months ago by sminnee

  • cc set to ischommer, sminnee
  • harvest_task set to (Unknown)
  • invoice_sent set to 0
  • milestone set to 2.2.2 feature-lock

This happens because they both add a country field to the form.

One solution here is to make addFieldToTab() only add the field if it doesn't already exist. That would make this a core-change, which could be done in 2.2.2.

Ingo - what do you think?

Changed 9 months ago by sminnee

  • owner changed from sharvey to sminnee
  • description changed from 've installed silverstripe.2.1.DailyBuild.2007-08-01 and I get following error when clicking to edit a user account in the security admin part: ERROR:Error 256: collateDataFields() I noticed that a field called 'Country' appears twice. At l28 in C:\xampp\htdocs\projects\AJAX\silverstripe-v2.0\sapphire\forms\FieldSet.php user_error(collateDataFields() I noticed that a field called 'Country' appears twice.,256) line 28 of FieldSet.php FieldSet->collateDataFields(Array) line 17 of FieldSet.php FieldSet->dataFields() line 421 of Form.php Form->loadDataFrom(Member) line 176 of MemberTableField.php MemberTableField->DetailForm() line of call_user_func_array(Array,Array) line 376 of ViewableData.php ViewableData->XML_val(DetailForm,,1) line 19 of .cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField_popup.ss include(C:\WINDOWS\Temp\silverstripe-cache\.cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField_popup.ss) line 190 of SSViewer.php SSViewer->process(MemberTableField) line 720 of ViewableData.php ViewableData->renderWith(ComplexTableField_popup) line 349 of ComplexTableField.php ComplexTableField->edit() line 523 of Form.php Form->callfieldmethod(Array,Form) line 134 of Controller.php Controller->run(Array) line 48 of Director.php Director::direct(/admin/security/index/1) line 101 of main.php I removed the forum module and now the problem is solved. SO probably there is a conflict between e-commerce and forum module. I checked in the member table and now 1 of the two country columns is removed. to In order to support multiple roles including the same field - e.g., Country - addFieldToTab() should ignore requests to add a field that already exists in the field, if the field is a data field. ----- === Country in E-commerce and forum module for member === 've installed silverstripe.2.1.DailyBuild.2007-08-01 and I get following error when clicking to edit a user account in the security admin part: ERROR:Error 256: collateDataFields() I noticed that a field called 'Country' appears twice. At l28 in C:\xampp\htdocs\projects\AJAX\silverstripe-v2.0\sapphire\forms\FieldSet.php user_error(collateDataFields() I noticed that a field called 'Country' appears twice.,256) line 28 of FieldSet.php FieldSet->collateDataFields(Array) line 17 of FieldSet.php FieldSet->dataFields() line 421 of Form.php Form->loadDataFrom(Member) line 176 of MemberTableField.php MemberTableField->DetailForm() line of call_user_func_array(Array,Array) line 376 of ViewableData.php ViewableData->XML_val(DetailForm,,1) line 19 of .cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField_popup.ss include(C:\WINDOWS\Temp\silverstripe-cache\.cacheC..xampp.htdocs.projects.AJAX.silverstripe-v2.0.sapphire.templates.ComplexTableField_popup.ss) line 190 of SSViewer.php SSViewer->process(MemberTableField) line 720 of ViewableData.php ViewableData->renderWith(ComplexTableField_popup) line 349 of ComplexTableField.php ComplexTableField->edit() line 523 of Form.php Form->callfieldmethod(Array,Form) line 134 of Controller.php Controller->run(Array) line 48 of Director.php Director::direct(/admin/security/index/1) line 101 of main.php I removed the forum module and now the problem is solved. SO probably there is a conflict between e-commerce and forum module. I checked in the member table and now 1 of the two country columns is removed.
  • summary changed from Country in E-commerce and forum module for member to Make addFieldToTab() ignore duplicates

Changed 8 months ago by sminnee

  • type changed from defect to enhancement

Changed 8 months ago by sminnee

  • milestone changed from 2.2.2 feature-lock to 2.2.3 feature-lock

Changed 5 months ago by sharvey

  • component changed from Modules - ecommerce to Sapphire Framework

Changed 3 months ago by sharvey

Patch with current work so far (including a test)

Changed 3 months ago by sharvey

Hey Sam, I've attached a patch of the current work done so far.

It includes a test, but there's a slight problem - the CMS doesn't appear to work, complaining of a "Root" node that doesn't exist whenever you try load a page. I can take a look at this next open source time.

Changed 1 month ago by sminnee

Fixed in r62218.

Changed 1 month ago by sharvey

$this->containerFieldSet->rootFieldSet() on line 534 of FormField?.php returns on the first line, but the second and third lines of code don't get used? Running all tests through TestRunner? produces:

Fatal error: Call to a member function rootFieldSet() on a non-object in /Users/sharvey/Sites/trunkproj/sapphire/forms/FormField.php on line 534

I can confirm this by visiting the checkout page in ecommerce/trunk too.

Changed 1 month ago by sminnee

  • status changed from new to closed
  • resolution set to fixed

Good point, Sean - buildbot picked it up too :-)

Fixed in r62275.

Note: See TracTickets for help on using tickets.