Skip to content

Commit

Permalink
Merge pull request #2 from wedevelopnl/fix/child-fields-editable
Browse files Browse the repository at this point in the history
Child widget fields should now properly propagate to the related widget
  • Loading branch information
DRuiter authored May 11, 2023
2 parents bb96d7e + 36f7ad7 commit 9d534ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"silverstripe/cms": "^4.11",
"dnadesign/silverstripe-elemental": "^4.9",
"sheadawson/silverstripe-dependentdropdownfield": "^2",
"unclecheese/display-logic": "^2.0"
"unclecheese/display-logic": "^2.0",
"stevie-mayhew/hasoneedit": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4"
Expand Down
9 changes: 8 additions & 1 deletion src/Element/ElementWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WeDevelop\ElementalWidget\Element;

use DNADesign\Elemental\Models\BaseElement;
use SGN\HasOneEdit\HasOneEdit;
use Sheadawson\DependentDropdown\Forms\DependentDropdownField;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
Expand Down Expand Up @@ -122,9 +123,15 @@ public function getCMSFields(): FieldList

$widgetFields->removeByName([
'Title',
'Root.Main',
'Main',
]);

// We'll loop over the widget fields to properly set the name so it maps to the relation
// instead of trying to edit it on the element itself
foreach($widgetFields->dataFields() as $field) {
$field->setName('Widget' . HasOneEdit::FIELD_SEPARATOR . $field->getName());
}

if ($this->SourcesFromCollection) {
$fields->addFieldToTab(
'Root.Widget',
Expand Down

0 comments on commit 9d534ae

Please sign in to comment.