Comments (8)
Here is the come to create new Widget:-
<?php
namespace Widgets\NewsUpdates;
use SilverStripe\Widgets\Model\Widget;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\ListboxField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\DropdownField;
use News\NewsDetailPage;
class NewsUpdates extends Widget{
private static $db = array(
'WidgetTitle' => 'Varchar',
'NewsPagesId_A' => 'Text',
'WidgetWidth' => 'Varchar',
'ViewAll' => 'Varchar'
);
private static $title = 'NewsUpdates HALF';
private static $cmsTitle = 'NewsUpdates';
private static $description = 'Description goes here';
private static $many_many = [
//'NewsPagesId' => NewsDetailPage::class,
];
public function getCMSFields(){
$news_detail = NewsDetailPage::get()->map('ID','Title')->toArray();
//print_r( $news_detail );
//print_r($this->NewsPagesId_A);exit;
//$news_detail = array("1"=>"one","2"=>"two","3"=>"three");
$f = new FieldList(
new TextField('WidgetTitle', 'Title'),
new TextField('ViewAll', 'View all link'),
ListboxField::create('NewsPagesId_A','Select newsfff',$news_detail),
DropdownField::create('WidgetWidth','Widget Width',[
'12' => 'FULL',
'6' => 'HALF',
'4' => '1/3'
])
);
return $f;
}
}
from silverstripe-widgets.
Would you mind sharing the code for your custom widget please?
from silverstripe-widgets.
from silverstripe-widgets.
I don't have Skype. If possible, you could remove any sensitive code from the file and post it here or in a GitHub Gist. If not, you can reach me on the Silverstripe Community Slack channel.
from silverstripe-widgets.
I don't have Skype. If possible, you could remove any sensitive code from the file and post it here or in a GitHub Gist. If not, you can reach me on the Silverstripe Community Slack channel.
Okay! Thanks for your response
from silverstripe-widgets.
Any luck?
from silverstripe-widgets.
Got my mistake.
To fix this i have to use "many many" relationship.
private static $many_many = [
'NewsPagesId' => NewsDetailPage::class,
];
Add following cms field:-
ListboxField::create('NewsPagesId','Select news',$news_detail, **$this->NewsPagesId()** )
from silverstripe-widgets.
closed as not a bug, then
from silverstripe-widgets.
Related Issues (20)
- Method 'getRequest' does not exist on 'SilverStripe\Forms\Form' HOT 4
- ENHANCEMENT Apply Versioned extension to Widget model (v4 only) HOT 3
- Fails to load compass HOT 9
- Widgets syncronize? HOT 2
- SS4 WidgetAreaEditor missing namespace HOT 2
- 500 fatal error when trying to add a widget to a page HOT 1
- Check and update module for SS4 compatibility where necessary HOT 1
- Rename HTML Content widget HOT 9
- Widget UX: Widgets appear on incompatible page types HOT 1
- Custom widget not being "Published" HOT 19
- Can't install for SS2.3 and blog2.5 HOT 1
- WidgetAreaID SQL error when adding WidgetArea to a child of Page HOT 7
- control tag is not working HOT 2
- DOCS README needs updating HOT 4
- [Warning] Invalid argument supplied for foreach() on 1.3 release running on SS 3.* HOT 2
- Split screen editing of widgets on a blog page shows TinyMCE too narrow HOT 5
- SS 4.5.1 Duplicate lits of 'Available Widgets' in Silverstripe backened. HOT 2
- Getting Widgets of Another Top Pages(This is Wrong) HOT 1
- Duplicating a page with Widgets doesn't assign new SideBarID HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silverstripe-widgets.