Skip to content

DIA-NZ/silverstripe-nestedcheckboxsetfield

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silverstripe-nestedcheckboxsetfield

This adds an extra level to a CheckboxSetField, which provides some structure to a large dataset.

Example Usage

The below will produce a set of nested fields where each Tag (which is selectable) sits under a Tag Category (just a heading, not selectable).

class Page extends SiteTree { static $many_many = array( 'PageTags' => 'Tag' );

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

    $fields->insertBefore(
        NestedCheckboxSetField::create('PageTags', 'Page Tags')
            ->setRootClass('TagCategory')
            ->setRootTitle('Title')
            ->setChildRelation('Tags')
            ->setChildTitle('Title'),
        'Content'
    );
}

}

class Tag extends DataObject { static $db = array( 'Title' => 'Varchar(100)' );

static $has_one = array(
    'Category' => 'TagCategory'
);

}

class TagCategory extends DataObject { static $db = array( 'Title' => 'Varchar(100)' );

static $has_many = array(
    'Tags' => 'Tag'
);

}

About

A standard CheckboxsetField which is nested by another level of relationship

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 83.5%
  • Scheme 13.3%
  • CSS 3.2%