Output metadata field description when editing Content Component Template


(Kieran) #1

Is there a reason that metadata field descriptions do not show in admin mode when editing a CCT?

We can see metadata field descriptions when looking at the metadata screen of an asset, but when editing a CCT on the content page of an asset, only field names, IDs and fields are output by default.

If I want to show a description to make it easier for an editor that is filling out the CCT, I have to create a custom edit layout for each component, and for each field I have to include keywords for field title, field input and field description: (%globals_asset_data_attributes:111111^json_decode^index:description^index:value%)

Seems a bit silly to me, but perhaps there’s a reason, before I log this as a bug.


(John gill) #2

I have pondered this in the past because descriptions are shown in CCTs in _edit but not _admin.

From core/assets/metadata/metadata_field/metadata_field_edit_fns.inc

        /**
         * Simple wrapper for determining whether to print the backend
         * or simple edit value interface for this metadata field and then
         * call the relevant print method
         *
         * @param bool  $using_template    are we using a content container template
         * @param bool  $from_keyword      is this field being printed via a keyword
         * @param array $content           the content element to be printed
         * @return void
         */
        public function paintEditInterface($using_template, $from_keyword, $content)
        {
                if( $this->useSimpleEditFormat($using_template, $from_keyword) ) {
                        $this->printSimpleEditInterface($content['default'], $content['metadata']);
                } else {
                        $this->printEditInterface($content['default'], $content['metadata'], $content['description'] );
                }
        }


        /**
         * Find out whether we should print in simple edit mode or not
         *
         * @param  bool  $using_template    are we using a content container template
         * @param  bool  $from_keyword      is this field being printed via a keyword
         * @return bool
         */
        private function useSimpleEditFormat($using_template = FALSE, $from_keyword = FALSE)
        {
                $inBackend = $this->paintInBackend();
                if ($inBackend && $using_template) { return TRUE; }
                if (!$inBackend && $from_keyword) { return TRUE; }
                return FALSE;
        }

It was clearly a deliberate distinction between “EditInterface” and “SimpleEditInterface” at one point, almost certainly before CCTs existed. When they were added they somehow got the SImpleEdit version not the Edit, so probably just an accident of history.

I agree that the description should be shown in the uncustomised edit layout of a CCT.


(Kieran) #3

Oh wow, thanks @JohnGill !
@Bart do you know the history here and is there a reason to keep it this way? Makes life a pain when trying to have non-technical people add CCTs and fill them in.


(John gill) #4

For funzies I took before and after screenshots of what a CCT looks like if you modify the code I pasted before to replace SimpleEdit with Edit

image


image


(Bart Banda) #5

Hey guys, yep this is a bug that we have in our backlog to fix.
I’ll see if we can get it moved up a bit…