Skip to content
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

No tags listed (No result found) #169

Open
muppsy007 opened this issue Aug 5, 2020 · 3 comments
Open

No tags listed (No result found) #169

muppsy007 opened this issue Aug 5, 2020 · 3 comments

Comments

@muppsy007
Copy link

muppsy007 commented Aug 5, 2020

Version 2 on SS 4.

namespace MyCo\Events;

use SilverStripe\ORM\DataObject;

class EventCategory extends DataObject
{

    private static $table_name = "EventCategory";

    private static $db = [
        'Title' => 'Varchar(100)'
    ];

    private static $belongs_many_many = [
        'Events' => Event::class
    ];
}

There are 6 records in the EventCategory database table

namespace MyCo\Events;

use SilverStripe\ORM\DataObject;
use SilverStripe\TagField\TagField;

class Event extends DataObject 
{

    private static $table_name = 'Event';

    private static $many_many =[
        'EventCategories' => EventCategory::class
    ];

   public static getCMSFields() {
       $fields = parent::getCMSFields();

        // Categories tagfield
        $fields->removeByName('EventCategories');
        $categoryField = TagField::create(
            'EventCategories',
            'Event Categories',
            EventCategory::get(),
            $this->EventCategories()
        );

        $fields->addFieldToTab('Root.Main', $categoryField);

       return $fields
   }

TagField displays fine on page. But when I click into it, none of the records in the EventCategory table show up. It just displays a short dropdown with "No results found". I've even confirmed that it has access to the six records just above the tagField creation by spitting out EventCategory::get(). No errors in JS console.

What have I done wrong? It looks identical to the the Readme example to me.

@muppsy007
Copy link
Author

Update: I find it doesn't matter what I throw at TagField. It doesn't display any options in the list. This exhibits the same behavior just passing it SiteTree.

$categoryField = TagField::create(
            'EventCategories',
            'Event Categories',
            SiteTree::get(),
            $this->EventCategories()
        );

@muppsy007
Copy link
Author

muppsy007 commented Aug 5, 2020

Update: I found that ->setShouldLazyLoad(true) loaded the list items fine with a slight delay, so tried ->setShouldLazyLoad(false) and this works now.

Not sure why. Other sites I have used this module on don't require that.

It also doesn't appear to be consistent as a work around. I created a second tagfield for a different relationship and evey with setShouldLazyLoad(false), it still won't load items. But it will if I use setShouldLazyLoad(true).

Actual version used is 2.1.1

@dnsl48
Copy link
Contributor

dnsl48 commented Aug 18, 2020

Hi, thank you for reporting that!
What exact version of CMS Recipe you have?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants