2017 © Pedro Peláez
 

silverstripe-module silverstripe-nestedcheckboxsetfield

Adds a level of nesting to a CheckboxSetField using a has_many/has_one relationship

image

madmatt/silverstripe-nestedcheckboxsetfield

Adds a level of nesting to a CheckboxSetField using a has_many/has_one relationship

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 7 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

silverstripe-nestedcheckboxsetfield

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

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)., (*2)

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

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

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

}, (*4)

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

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

}, (*6)

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

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

}, (*8)

The Versions

18/07 2013

dev-master

9999999-dev https://github.com/madmatt/silverstripe-nestedcheckboxsetfield

Adds a level of nesting to a CheckboxSetField using a has_many/has_one relationship

  Sources   Download

WTFPL

The Requires

 

silverstripe forms