753 Posts in 310 Topics by 289 members
| Go to End | ||
| Author | Topic: | 4686 Views |
-
Re: TreeDropdownField doesn't work with widget

29 January 2009 at 3:32am
Why do you have it extending ImageWidget? It's a subclass of DropdownField. Use the code as I gave it to you, and add the class anywhere in your ImageWidget.php file.
Then you can add new SimpleTreeDropdownField to your fieldset.
-
Re: TreeDropdownField doesn't work with widget

9 February 2010 at 3:11pm
UncleCheese, thanks very much for the workaround class. I especially like the way you can just change the name from TreeDropdownField to SimpleTreeDropdownField in the fieldset and it works.
-
Re: TreeDropdownField doesn't work with widget

18 May 2011 at 8:44am
I too am using SimpleTreeDropdownField in getCMSFields_forPopup() and it works fine (thanks as always @UC). Question, though, in my DataObjectManager, I'd like to get the Title of the selected page in the SiteTree to display instead of the ID. In my DataObject, I've got:
public static $has_one = array(
"LinkedPage" => "SiteTree"
);
.....
public static $field_names = array(
"Title" => "Title",
"PageName" => "Link to Page",
"Content" => "Content"
);
.....
public function PageName() {
$Page = DataObject::get_by_id("SiteTree", $this->LinkedPageID);
return $Page->Title;
}But obviously I'm getting an "Unknown column 'PageName' in 'field list'" when I click on the page in the CMS. Any idea how I can accomplish what I want here?
Thanks again,
Garrett -
Re: TreeDropdownField doesn't work with widget

30 November 2012 at 3:33am Last edited: 30 November 2012 3:34am
I've found where is the problem in using the TreeDropDownField in Widgets (in SS 2.4.7), and I have a simple workaround for that.
The problem is that the method Form::handleField() is not able to find and return the field to the ajax call that is thrown when you click on the dropdown.
Since, in cms/javascript/WidgetAreaEditor.js the name of dropdown fields that are in widgets are overwritten with the string "Widget_TDF_Endpoint", it suffices then to modify the sapphire/forms/Form.php and add this few lines to the handleField method (those between START_MOD and END_MOD):
function handleField($request) {
$field = $this->dataFieldByName($request->param('FieldName'));
if($field) {
return $field;
} else {
//START_MOD: TreeDropdownField in Widgets
$fieldName = $request->param('FieldName');
if ($fieldName == 'Widget_TDF_Endpoint') {
return new TreeDropdownField($fieldName, null, 'SiteTree');
}
//END_MOD
// falling back to fieldByName, e.g. for getting tabs
return $this->Fields()->fieldByName($request->param('FieldName'));
}
}I hope this helps.
| 4686 Views | ||
| Go to Top |


