Open stojg opened 12 years ago
I'm also getting the same error using TreeDropdownField, should I open a separate bug for this?
Hi, sorry for the late reply, I've somehow disabled my github notifications.
Please do, even though the problem is basically the same for all of the more 'advanced' gridfields, it helps testing any solutions.
I've come as far realizing that the whole getCMSFields from Admin -> Page -> WidgetArea -> Widget doesn't work, and therefore some fields can't get hold on the actually Form or Controller.
What needs to be done is to refactor the whole thing. :/
That sounds like a big project!
I've noticed that lots of page functions don't seem to work with widgets, would this be something that would be included in a refactor? For example I wanted to get the URL from a Page ID by using $FooID.Link, but I had to write a custom function using SiteTree::get()->byID($pageID)->Link() instead.
Hi!
I'am using widgets for an upcoming project, and it is a must to enable the possibility of uploading images directly on widget creation. So I wanted to know if there are any news on that issue, if there's a workaround and if I may help somehow.
Could it also be, that has_many and many_many relations on widget do not work? I found out, that the according relation tables will not be created on /dev/build/
Thanks in advance, Markus
Amo666, you can attach an image this way...http://pastebin.com/wKiHApmq
Hi! Thank's for the hint, I already did it that way, but it is not the solution I need. Our client needs a perfect usability, so a user should have the ability to upload an image directly on widget creation.
I now use "GridFieldAddNewMultiClass" from the gridfieldextensions by @ajshort for choosing different widget classes. I use the standard silverstripe forms, so I can use standard formfields like the UploadField. Further I can generate a live preview of the widget in the Grid and on creation with a LiteralField. GridFieldOrderableRows enables Drag&Drop. That works for me.
I have created a module that somewhat encapsulates @Amo666 's idea: https://github.com/burnbright/silverstripe-widgetpages.
In a nutshell:
$fields->removeByName("SideBar");
$fields->addFieldToTab("Root.Widgets",
GridField::create("SideBar","SideBar",
$this->SideBar()->Widgets(),
GridFieldConfig_RecordEditor::create()
->removeComponentsByType("GridFieldAddNewButton")
->addComponent(new GridFieldAddNewMultiClass())
->addComponent(new GridFieldOrderableRows())
)
);
I have created a module that transform @jedateach in an extension, and in addition to provide a workaround for this issue it give some enhancement to the original widget module, like many_many relationship instead of the original has_many and an alternative templating strategy. Here you are the link:
http://addons.silverstripe.org/add-ons/zirak/widget-pages-extension
Multiselect Module does not work inside widget
why has this important issue not been fixed for many years?
@nguyenhoanglong1331 since this issue is so old I imagine parts of it are no longer relevant. If you’re still experiencing this problem could you please provide us with your composer.json contents and some steps to reproduce?
Here is my composer.json
{
"name": "silverstripe/installer",
"type": "silverstripe-recipe",
"description": "The SilverStripe Framework Installer",
"require": {
"php": ">=5.6.0",
"silverstripe/recipe-plugin": "^1",
"silverstripe/recipe-cms": "1.1.1@stable",
"silverstripe-themes/simple": "~3.2.0",
"unclecheese/betterbuttons": "2.x-dev",
"silverstripe/widgets": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"extra": {
"branch-alias": {
"4.x-dev": "4.2.x-dev",
"dev-master": "5.x-dev"
},
"project-files-installed": [
"mysite/.htaccess",
"mysite/_config.php",
"mysite/_config/mysite.yml",
"mysite/code/Page.php",
"mysite/code/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
},
"config": {
"process-timeout": 600
},
"prefer-stable": true,
"minimum-stability": "dev"
}
and in the widget file
public function getCMSFields()
{
return new FieldList(
new HTMLEditorField('Paragraph', 'Content'),
new NumericField('MaxWidth', 'Max Width'),
new NumericField('PaddingBottom', 'Padding Bottom'),
new TextField('Color', 'Color'),
new TextField('BackgroundColor', 'Background Color'),
new UploadField('Photo','Photo')
//UploadFiled::create('Photo','Photo')
);
}
All the other fileds are working good, but when i put the UploadField, it throws an error
Thank you @nguyenhoanglong1331
+1 to this issue. I'm also using the solution with GridFieldAddNewMultiClass
for now, but it'd be awesome to use the original interface, which is much nicer.
Suggestion: ditch widgets and use Shea Dawson's blocks module for SS3 or elemental for SS4.
public function getSchemaDataDefaults() { $defaults = parent::getSchemaDataDefaults(); $uploadLink = $this->Link('upload'); $defaults['data']['createFileEndpoint'] = [ 'url' => $uploadLink, 'method' => 'post', 'payloadFormat' => 'urlencoded', ]; $defaults['data']['maxFiles'] = $this->getAllowedMaxFileNumber(); $defaults['data']['multi'] = $this->getIsMultiUpload(); $defaults['data']['parentid'] = $this->getFolderID(); $defaults['data']['canUpload'] = $this->getUploadEnabled(); $defaults['data']['canAttach'] = $this->getAttachEnabled(); return $defaults; }
The issue happen because the input can not get the form when calling $this->Link('upload') function (file SilverStripe\AssetAdmin\Forms\UploadField.php) Can anyone help me to get over it ?
@grandcreation you might have more luck if you move that problem into the silverstripe-asset-admin repository
This is the error message:
Fatal error: Call to a member function FormAction() on a non-object in /framework/forms/FormField.php on line 139
To reproduce: