code/extensions/SeedTaxonomyTermExtension.php
public function createReverseTagField($name) {
        $belongs_many_many = $this->owner->config()->belongs_many_many;
        if (!isset($belongs_many_many[$name]))
        {
            return null;
        }
        $className = $belongs_many_many[$name];
        $s = singleton(($className === 'SiteTree') ? 'Page' : $className);
        $visibleName = $s->plural_name();
        $field = null;
        if ($className::has_extension('Hierarchy'))
        {
            $field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className);
        }
        else
        {
            $records = array();
            foreach ($className::get() as $record)
            {
                if ($record->canView())
                {
                    $records[] = $record;
                }
            }
            $field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true);
        }
        if ($field)
        {
            $field->setRightTitle($visibleName.' ('.$className.') using this tag');
        }
        return $field;
    }
public function createReverseTagField($name) {
        $belongs_many_many = $this->owner->config()->belongs_many_many;
        if (!isset($belongs_many_many[$name]))
        {
            return null;
        }
        $className = $belongs_many_many[$name];
        $s = singleton(($className === 'SiteTree') ? 'Page' : $className);
        $visibleName = $s->plural_name();
        $field = null;
        if ($className::has_extension('Hierarchy'))
        {
            $field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className);
        }
        else
        {
            $records = array();
            foreach ($className::get() as $record)
            {
                if ($record->canView())
                {
                    $records[] = $record;
                }
            }
            $field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true);
        }
        if ($field)
        {
            $field->setRightTitle($visibleName.' ('.$className.') using this tag');
        }
        return $field;
    }
public function createReverseTagField ( $ name ) { $ belongs_many_many = $ this -> owner -> config ( ) -> belongs_many_many ; if ( ! isset ( $ belongs_many_many [ $ name ] ) ) { return null ; } $ className = $ belongs_many_many [ $ name ] ; $ s = singleton ( ( $ className === 'SiteTree' ) ? 'Page' : $ className ) ; $ visibleName = $ s -> plural_name ( ) ; $ field = null ; if ( $ className :: has_extension ( 'Hierarchy' ) ) { $ field = TreeMultiselectField :: create ( $ name , 'Tagged ' . $ visibleName , $ className ) ; } else { $ records = array ( ) ; foreach ( $ className :: get ( ) as $ record ) { if ( $ record -> canView ( ) ) { $ records [ ] = $ record ; } } $ field = ListboxField :: create ( $ name , 'Tagged ' . $ visibleName , $ className :: get ( ) -> map ( ) -> toArray ( ) ) -> setMultiple ( true ) ; } if ( $ field ) { $ field -> setRightTitle ( $ visibleName . ' (' . $ className . ') using this tag' ) ; } return $ field ; }
Setup the appropriate field to manage tagging for a belongs_many_many
relationship.
Setup the appropriate field to manage tagging for a belongs_many_many relationship .