public function addQueryFields($fields)
    {
        /** @var DMSDocument $doc */
        $doc = singleton('DMSDocument');
        /** @var FormField $field */
        $dmsDocFields = $doc->scaffoldSearchFields(array('fieldClasses' => true));
        $membersMap = Member::get()->map('ID', 'Name')->toArray();
        asort($membersMap);

        foreach ($dmsDocFields as $field) {
            if ($field instanceof ListboxField) {
                $map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap;
                $field->setMultiple(true)->setSource($map);

                if ($field->getName() === 'Tags__ID') {
                    $field->setRightTitle(
                        _t(
                            'DMSDocumentSet.TAGS_RIGHT_TITLE',
                            'Tags can be set in the taxonomy area, and can be assigned when editing a document.'
                        )
                    );
                }
            }
        }
        $keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray());

        // Now lastly add the sort fields
        $sortedBy = FieldGroup::create('SortedBy', array(
            DropdownField::create('SortBy', '', array(
                'LastEdited'  => 'Last changed',
                'Created'     => 'Created',
                'Title'       => 'Document title',
            ), 'LastEdited'),
            DropdownField::create(
                'SortByDirection',
                '',
                array(
                    'DESC' => _t('DMSDocumentSet.DIRECTION_DESCENDING', 'Descending'),
                    'ASC' => _t('DMSDocumentSet.DIRECTION_ASCENDING', 'Ascending')
                ),
                'DESC'
            ),
        ));

        $sortedBy->setTitle(_t('DMSDocumentSet.SORTED_BY', 'Sort the document set by:'));
        $fields->addFieldsToTab(
            'Root.QueryBuilder',
            array(
                LiteralField::create(
                    'GridFieldNotice',
                    '<p class="message warning">' . _t(
                        'DMSDocumentSet.QUERY_BUILDER_NOTICE',
                        'The query builder provides the ability to add documents to a document set based on the ' .
                        'filters below. Please note that the set will be built using this criteria when you save the ' .
                        'form. This set will not be dynamically updated (see the documentation for more information).'
                    ) . '</p>'
                ),
                $keyValPairs,
                $sortedBy
            )
        );
    }
public function addQueryFields($fields)
    {
        /** @var DMSDocument $doc */
        $doc = singleton('DMSDocument');
        /** @var FormField $field */
        $dmsDocFields = $doc->scaffoldSearchFields(array('fieldClasses' => true));
        $membersMap = Member::get()->map('ID', 'Name')->toArray();
        asort($membersMap);

        foreach ($dmsDocFields as $field) {
            if ($field instanceof ListboxField) {
                $map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap;
                $field->setMultiple(true)->setSource($map);

                if ($field->getName() === 'Tags__ID') {
                    $field->setRightTitle(
                        _t(
                            'DMSDocumentSet.TAGS_RIGHT_TITLE',
                            'Tags can be set in the taxonomy area, and can be assigned when editing a document.'
                        )
                    );
                }
            }
        }
        $keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray());

        // Now lastly add the sort fields
        $sortedBy = FieldGroup::create('SortedBy', array(
            DropdownField::create('SortBy', '', array(
                'LastEdited'  => 'Last changed',
                'Created'     => 'Created',
                'Title'       => 'Document title',
            ), 'LastEdited'),
            DropdownField::create(
                'SortByDirection',
                '',
                array(
                    'DESC' => _t('DMSDocumentSet.DIRECTION_DESCENDING', 'Descending'),
                    'ASC' => _t('DMSDocumentSet.DIRECTION_ASCENDING', 'Ascending')
                ),
                'DESC'
            ),
        ));

        $sortedBy->setTitle(_t('DMSDocumentSet.SORTED_BY', 'Sort the document set by:'));
        $fields->addFieldsToTab(
            'Root.QueryBuilder',
            array(
                LiteralField::create(
                    'GridFieldNotice',
                    '<p class="message warning">' . _t(
                        'DMSDocumentSet.QUERY_BUILDER_NOTICE',
                        'The query builder provides the ability to add documents to a document set based on the ' .
                        'filters below. Please note that the set will be built using this criteria when you save the ' .
                        'form. This set will not be dynamically updated (see the documentation for more information).'
                    ) . '</p>'
                ),
                $keyValPairs,
                $sortedBy
            )
        );
    }
public function addQueryFields ( $ fields ) { /** @var DMSDocument $doc */ $ doc = singleton ( 'DMSDocument' ) ; /** @var FormField $field */ $ dmsDocFields = $ doc -> scaffoldSearchFields ( array ( 'fieldClasses' => true ) ) ; $ membersMap = Member :: get ( ) -> map ( 'ID' , 'Name' ) -> toArray ( ) ; asort ( $ membersMap ) ; foreach ( $ dmsDocFields as $ field ) { if ( $ field instanceof ListboxField ) { $ map = ( $ field -> getName ( ) === 'Tags__ID' ) ? $ doc -> getAllTagsMap ( ) : $ membersMap ; $ field -> setMultiple ( true ) -> setSource ( $ map ) ; if ( $ field -> getName ( ) === 'Tags__ID' ) { $ field -> setRightTitle ( _t ( 'DMSDocumentSet.TAGS_RIGHT_TITLE' , 'Tags can be set in the taxonomy area, and can be assigned when editing a document.' ) ) ; } } } $ keyValPairs = DMSJsonField :: create ( 'KeyValuePairs' , $ dmsDocFields -> toArray ( ) ) ; // Now lastly add the sort fields $ sortedBy = FieldGroup :: create ( 'SortedBy' , array ( DropdownField :: create ( 'SortBy' , '' , array ( 'LastEdited' => 'Last changed' , 'Created' => 'Created' , 'Title' => 'Document title' , ) , 'LastEdited' ) , DropdownField :: create ( 'SortByDirection' , '' , array ( 'DESC' => _t ( 'DMSDocumentSet.DIRECTION_DESCENDING' , 'Descending' ) , 'ASC' => _t ( 'DMSDocumentSet.DIRECTION_ASCENDING' , 'Ascending' ) ) , 'DESC' ) , ) ) ; $ sortedBy -> setTitle ( _t ( 'DMSDocumentSet.SORTED_BY' , 'Sort the document set by:' ) ) ; $ fields -> addFieldsToTab ( 'Root.QueryBuilder' , array ( LiteralField :: create ( 'GridFieldNotice' , '<p class="message warning">' . _t ( 'DMSDocumentSet.QUERY_BUILDER_NOTICE' , 'The query builder provides the ability to add documents to a document set based on the ' . 'filters below. Please note that the set will be built using this criteria when you save the ' . 'form. This set will not be dynamically updated (see the documentation for more information).' ) . '</p>' ) , $ keyValPairs , $ sortedBy ) ) ; }
Adds the query fields to build the document logic to the DMSDocumentSet.

@param FieldList $fields
Adds the query fields to build the document logic to the DMSDocumentSet .