-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to toggle off, switched on by default #51
Comments
What version of SilverStripe are you using? Also if you're in firefox and have firebug are there any javascript errors? Or stack dumps coming from PHP via ajax? |
3.1 No console errors. The only thing that fires off is: admin/employees/Employee/EditForm/field/Employee Which returns the form with no errors. |
I'll have a look, mind posting your implementation code in your ModelAdmin extension and the model for Employee (just the $db, $has_one, $has_many, etc don't need the full class)? |
ModelAdmin class: public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
if ($gridField = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass))) {
$gridField->getConfig()->addComponent(new GridFieldSortableRows('Sort'));
}
return $form;
} Employee DB fields: Employee: #extends DataObject
db:
Name: Varchar(255)
Position: Varchar(255)
Biography: HTMLText
ContactDetails: HTMLText
URLSegment: Varchar(255)
LeadText: HTMLText
Sort: Int
default_sort: '"Sort" ASC' We aren't actually using a relationship, we just want to sort them so they are always available in that order. |
Thanks, I'll give it a go and see what I come up with. Will be tonight or possibly the weekend. But I'll try to look into it tonight though. |
I'm having a hard time reproducing this are you using the latest master? If you are can you post your full model admin and your full Employee class. It could be simply that the session data for the GridField is messed up try restarting the browser or putting it into private mode see what happens then. I've seen from time to time the Grid State in the session gets confused, never been able to solidly reproduce it though. |
I've tried it in private browsing mode and a new browser and it still happens. Here are the relevant files: <?php
class Employee extends DataObject {
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->fieldByName('Root.Main.ContactDetails')
->setRows(5);
$fields->fieldByName('Root.Main.Image')
->setFolderName('Uploads/employees');
$fields->fieldByName('Root.Main.LeadText')
->setRows(3);
$fields->fieldByName('Root.Main.VCard')
->setFolderName('Uploads/vcards')
->getValidator()
->setAllowedExtensions(array(
'vcf',
'VCF',
));
$fields->removeByName('URLSegment');
$fields->removeByName('Sort');
return $fields;
}
public function onBeforeWrite() {
parent::onBeforeWrite();
if(empty($this->URLSegment) || $this->isChanged('Name')) {
$this->URLSegment = $this->generateSegment();
}
}
/**
* Generates a URL segment
* @return string
*/
protected function generateSegment() {
$title = $this->Name;
$title = URLSegmentFilter::create()->filter($title);
return trim(substr($title, 0, 64), '-');
}
public function Link($parentPage = null) {
$parentPage = $parentPage ? $parentPage : EmployeePage::get()->first();
return Controller::join_links(
$parentPage->Link(),
$this->URLSegment
);
}
public function LinkOrCurrent($employeeID = null) {
if($employeeID && $employeeID == $this->ID) {
return 'current';
}
return 'link';
}
} Employee.yml Employee: #extends DataObject
db:
Name: Varchar(255)
Position: Varchar(255)
Biography: HTMLText
ContactDetails: HTMLText
URLSegment: Varchar(255)
LeadText: HTMLText
Sort: Int
has_one:
Image: Image
VCard: File
summary_fields:
Name: Name
Position: Position
default_sort: '"Sort" ASC' EmployeeAdmin.php <?php
class EmployeeAdmin extends ModelAdmin {
private static
$managed_models = array(
'Employee',
),
$menu_title = 'Employees',
$url_segment = 'employees';
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
if ($gridField = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass))) {
$gridField->getConfig()->addComponent(new GridFieldSortableRows('Sort'));
}
return $form;
}
} composer.json {
"name": "Redacted",
"description": "Redacted",
"version": "1",
"require": {
"php": ">=5.3.2",
"silverstripe/cms": "3.2.*@dev",
"silverstripe/framework": "3.2.*@dev",
"heyday/silverstripe-optimisedimage": "~2.0",
"silverstripe/userforms": "dev-master",
"silverstripe/googlesitemaps": "dev-master",
"monolog/monolog": "1.7.*@dev",
"undefinedoffset/sortablegridfield": "dev-master",
"tractorcow/silverstripe-fluent": "3.1.*@dev"
},
"config": {
"process-timeout": 600
},
"minimum-stability": "dev"
} And the composer.lock file {
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "0e5c7d74288e64b6c3bc1c06c059a234",
"packages": [
{
"name": "composer/installers",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/composer/installers.git",
"reference": "53c31d1c216b64c1da999d5d25a97fcbf6810515"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/installers/zipball/53c31d1c216b64c1da999d5d25a97fcbf6810515",
"reference": "53c31d1c216b64c1da999d5d25a97fcbf6810515",
"shasum": ""
},
"replace": {
"shama/baton": "*"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpunit/phpunit": "3.7.*"
},
"type": "composer-installer",
"extra": {
"class": "Composer\\Installers\\Installer",
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-0": {
"Composer\\Installers\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kyle Robinson Young",
"email": "[email protected]",
"homepage": "https://github.com/shama",
"role": "Developer"
}
],
"description": "A multi-framework Composer library installer",
"homepage": "http://composer.github.com/installers/",
"keywords": [
"TYPO3 CMS",
"TYPO3 Flow",
"TYPO3 Neos",
"agl",
"cakephp",
"codeigniter",
"concrete5",
"drupal",
"elgg",
"fuelphp",
"installer",
"joomla",
"kohana",
"laravel",
"li3",
"lithium",
"mako",
"modulework",
"phpbb",
"piwik",
"ppi",
"silverstripe",
"symfony",
"wordpress",
"zend"
],
"time": "2014-01-14 16:42:06"
},
{
"name": "heyday/silverstripe-optimisedimage",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/heyday/silverstripe-optimisedimage.git",
"reference": "3c52d92ec043d7c90876abb148bf985c41769ef0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/heyday/silverstripe-optimisedimage/zipball/3c52d92ec043d7c90876abb148bf985c41769ef0",
"reference": "3c52d92ec043d7c90876abb148bf985c41769ef0",
"shasum": ""
},
"require": {
"composer/installers": "~1.0",
"symfony/process": "~2.3"
},
"type": "silverstripe-module",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Cam Spiers",
"email": "[email protected]",
"role": "Developer"
}
],
"description": "Uses various binary tools like jpegoptim and optipng to optimise resampled images create by SilverStripe",
"time": "2014-01-02 09:34:02"
},
{
"name": "monolog/monolog",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "7f783c0ab09dc341f858882e2d2ce6fc36ca1351"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/7f783c0ab09dc341f858882e2d2ce6fc36ca1351",
"reference": "7f783c0ab09dc341f858882e2d2ce6fc36ca1351",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"require-dev": {
"aws/aws-sdk-php": "~2.4.8",
"doctrine/couchdb": "dev-master",
"mlehner/gelf-php": "1.0.*",
"phpunit/phpunit": "~3.7.0",
"raven/raven": "~0.5",
"ruflin/elastica": "0.90.*"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server",
"raven/raven": "Allow sending log messages to a Sentry server",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7.x-dev"
}
},
"autoload": {
"psr-0": {
"Monolog": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "[email protected]",
"homepage": "http://seld.be",
"role": "Developer"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "https://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"time": "2014-01-17 14:16:06"
},
{
"name": "psr/log",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "a78d6504ff5d4367497785ab2ade91db3a9fbe11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/a78d6504ff5d4367497785ab2ade91db3a9fbe11",
"reference": "a78d6504ff5d4367497785ab2ade91db3a9fbe11",
"shasum": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Psr\\Log\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2014-01-18 15:33:09"
},
{
"name": "silverstripe/cms",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/silverstripe/silverstripe-cms.git",
"reference": "c6082827dc25ab6bbbe0e1749a66acc74478afe9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silverstripe/silverstripe-cms/zipball/c6082827dc25ab6bbbe0e1749a66acc74478afe9",
"reference": "c6082827dc25ab6bbbe0e1749a66acc74478afe9",
"shasum": ""
},
"require": {
"composer/installers": "*",
"php": ">=5.3.2",
"silverstripe/framework": "3.2.x-dev",
"silverstripe/reports": "*"
},
"type": "silverstripe-module",
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
}
},
"autoload": {
"classmap": [
"tests/behat/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "SilverStripe",
"homepage": "http://silverstripe.com"
},
{
"name": "The SilverStripe Community",
"homepage": "http://silverstripe.org"
}
],
"description": "The SilverStripe Content Management System",
"homepage": "http://silverstripe.org",
"keywords": [
"cms",
"silverstripe"
],
"time": "2014-01-14 04:58:43"
},
{
"name": "silverstripe/framework",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/silverstripe/silverstripe-framework.git",
"reference": "b52a82185f25a8ce1e69ea65b4b91c35c5522016"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silverstripe/silverstripe-framework/zipball/b52a82185f25a8ce1e69ea65b4b91c35c5522016",
"reference": "b52a82185f25a8ce1e69ea65b4b91c35c5522016",
"shasum": ""
},
"require": {
"composer/installers": "*",
"php": ">=5.3.3"
},
"type": "silverstripe-module",
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
}
},
"autoload": {
"classmap": [
"tests/behat/features/bootstrap"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "SilverStripe",
"homepage": "http://silverstripe.com"
},
{
"name": "The SilverStripe Community",
"homepage": "http://silverstripe.org"
}
],
"description": "The SilverStripe framework",
"homepage": "http://silverstripe.org",
"keywords": [
"framework",
"silverstripe"
],
"time": "2014-01-09 06:54:37"
},
{
"name": "silverstripe/googlesitemaps",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/silverstripe-labs/silverstripe-googlesitemaps.git",
"reference": "a2297c43ef748025ddded140d4ad4320a88fd3ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silverstripe-labs/silverstripe-googlesitemaps/zipball/a2297c43ef748025ddded140d4ad4320a88fd3ea",
"reference": "a2297c43ef748025ddded140d4ad4320a88fd3ea",
"shasum": ""
},
"require": {
"silverstripe/framework": "~3.1"
},
"type": "silverstripe-module",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "Will Rossiter",
"email": "[email protected]",
"homepage": "http://wilr.github.com"
}
],
"description": "SilverStripe support for the Google Sitemaps XML system, enabling Google and other search engines to see all urls on your site. This helps your SilverStripe website rank well in search engines, and to encourage the information on your site to be discovered by Google quickly.",
"homepage": "https://github.com/silverstripe-labs/silverstripe-googlesitemaps",
"keywords": [
"googlesitemaps",
"seo",
"silverstripe"
],
"time": "2013-08-28 05:51:17"
},
{
"name": "silverstripe/reports",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/silverstripe-labs/silverstripe-reports.git",
"reference": "2303ce3ed0672ffa2675c8e5de546764c1070295"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silverstripe-labs/silverstripe-reports/zipball/2303ce3ed0672ffa2675c8e5de546764c1070295",
"reference": "2303ce3ed0672ffa2675c8e5de546764c1070295",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"silverstripe/framework": ">=3.1.x-dev"
},
"type": "silverstripe-module",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "SilverStripe",
"homepage": "http://silverstripe.com"
},
{
"name": "The SilverStripe Community",
"homepage": "http://silverstripe.org"
}
],
"homepage": "http://silverstripe.org",
"keywords": [
"cms",
"reports",
"silverstripe"
],
"time": "2013-11-05 03:43:51"
},
{
"name": "silverstripe/userforms",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/silverstripe/silverstripe-userforms.git",
"reference": "44ab7a507b877a90b754780a6e342a014f7a18ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silverstripe/silverstripe-userforms/zipball/44ab7a507b877a90b754780a6e342a014f7a18ce",
"reference": "44ab7a507b877a90b754780a6e342a014f7a18ce",
"shasum": ""
},
"require": {
"silverstripe/cms": ">=3.1.0",
"silverstripe/framework": ">=3.1.0"
},
"type": "silverstripe-module",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Will Rossiter",
"email": "[email protected]",
"homepage": "http://wilr.github.com"
}
],
"description": "UserForms enables CMS users to create dynamic forms via a drag and drop interface and without getting involved in any PHP code",
"keywords": [
"silverstripe",
"userforms"
],
"time": "2014-01-06 03:13:46"
},
{
"name": "symfony/process",
"version": "dev-master",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "d4b086ca4d6e192d8c2c64fe011159c8bc4c9daa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/d4b086ca4d6e192d8c2c64fe011159c8bc4c9daa",
"reference": "d4b086ca4d6e192d8c2c64fe011159c8bc4c9daa",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Process\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
"time": "2014-01-07 13:29:57"
},
{
"name": "tractorcow/silverstripe-fluent",
"version": "3.1.x-dev",
"source": {
"type": "git",
"url": "https://github.com/tractorcow/silverstripe-fluent.git",
"reference": "be8439bf28670d762243bee1f00275d0aa5a8763"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tractorcow/silverstripe-fluent/zipball/be8439bf28670d762243bee1f00275d0aa5a8763",
"reference": "be8439bf28670d762243bee1f00275d0aa5a8763",
"shasum": ""
},
"require": {
"composer/installers": "*",
"silverstripe/cms": ">=3.1.1",
"silverstripe/framework": ">=3.1.1"
},
"type": "silverstripe-module",
"extra": {
"installer-name": "fluent"
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Damian Mooyman",
"email": "[email protected]",
"homepage": "https://github.com/tractorcow",
"role": "Developer"
}
],
"description": "Simple localisation for Silverstripe",
"keywords": [
"language",
"locale",
"localisation",
"localization",
"multilingual",
"silverstripe",
"translation"
],
"time": "2014-01-20 22:35:08"
},
{
"name": "undefinedoffset/sortablegridfield",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/UndefinedOffset/SortableGridField.git",
"reference": "278b6d6844ab86cc7e37d0ce5ba416bb4210ed60"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/UndefinedOffset/SortableGridField/zipball/278b6d6844ab86cc7e37d0ce5ba416bb4210ed60",
"reference": "278b6d6844ab86cc7e37d0ce5ba416bb4210ed60",
"shasum": ""
},
"require": {
"composer/installers": "*",
"silverstripe/framework": "3.*"
},
"type": "silverstripe-module",
"extra": {
"installer-name": "sortablegridfield"
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Ed Chipman",
"homepage": "http://www.edchipman.ca",
"role": "Developer"
}
],
"description": "Adds drag and drop functionality to SilverStripe 3.0's GridField",
"keywords": [
"gridfield",
"silverstripe"
],
"time": "2014-01-10 14:56:36"
}
],
"packages-dev": [
],
"aliases": [
],
"minimum-stability": "dev",
"stability-flags": {
"silverstripe/cms": 20,
"silverstripe/framework": 20,
"silverstripe/userforms": 20,
"silverstripe/googlesitemaps": 20,
"monolog/monolog": 20,
"undefinedoffset/sortablegridfield": 20,
"tractorcow/silverstripe-fluent": 20
},
"platform": {
"php": ">=5.3.2"
},
"platform-dev": [
]
} Thanks! |
Wild guess, its probably something to do with using 3.2.x (aka master). I'm testing on SS 3.1.2 and 3.0.8 where it works as expected. If your intention is to use SS 3.1 try changing your requirement in your composer.json for silverstripe/framework and silverstripe/cms to 3.1.*@ stable (Minus the space after the @). Till 3.2 is closer to a beta SortableGridField likely will have issues. |
Right, this is an issue caused by silverstripe/silverstripe-framework#2522 Basically, now all properties of State are coming back as these GridState_Data objects, which aren't suited to holding non-array like values. I'll open a PR to fix this, but it's likely it won't work for people using older versions of framework. silverstripe/silverstripe-framework#2522 really needs reconsidering in my opinion and I'll raise that now. I'll also try to make the PR "backwards compatible" later. |
A fix for this has been added to the experimental branch, however this is staying on experimental because it is an issue with the core of 3.2 and the changes required break compatibility with 3.0 and 3.1. |
Makes sense. Let's hope I get some replies to my bug on silverstripe. |
The 'Allow drag and drop re-ordering' check box is checked by default and when trying to uncheck it, it automatically checks itself again.
This is when using SortableGridField in the ModelAdmin.
The text was updated successfully, but these errors were encountered: