public function viewModeEdit($viewMode, $id)
    {
        $this->_validateViewMode($viewMode);
        $instance = $this->_getOrThrow($id);
        $arrayContext = [
            'schema' => [
                'label_visibility' => ['type' => 'string'],
                'shortcodes' => ['type' => 'boolean'],
                'hidden' => ['type' => 'boolean'],
            ],
            'defaults' => [
                'label_visibility' => 'hidden',
                'shortcodes' => false,
                'hidden' => false,
            ],
            'errors' => []
        ];
        $viewModeInfo = $this->viewModes($viewMode);

        if ($this->request->data()) {
            $validator = $this->FieldInstances->validator('viewMode');
            $instance->validateViewModeSettings($this->request->data(), $validator, $viewMode);
            $errors = $validator->errors($this->request->data(), false);

            if (empty($errors)) {
                $instance->accessible('*', true);
                $viewModes = $instance->get('view_modes');
                $viewModes[$viewMode] = array_merge($viewModes[$viewMode], $this->request->data());
                $instance->set('view_modes', $viewModes);

                if ($this->FieldInstances->save($instance)) {
                    $this->Flash->success(__d('field', 'Field information was saved.'));
                    $this->redirect($this->referer());
                } else {
                    $this->Flash->danger(__d('field', 'Your information could not be saved.'));
                }
            } else {
                $this->Flash->danger(__d('field', 'View mode settings could not be saved.'));
                foreach ($errors as $field => $message) {
                    $arrayContext['errors'][$field] = $message;
                }
            }
        } else {
            $arrayContext['defaults'] = (array)$instance->view_modes[$viewMode];
            $this->request->data = $arrayContext['defaults'];
        }

        $this->title(__d('field', 'Configure View Mode'));
        $instance->accessible('settings', true);
        $this->set(compact('arrayContext', 'viewMode', 'viewModeInfo', 'instance'));
    }
public function viewModeEdit($viewMode, $id)
    {
        $this->_validateViewMode($viewMode);
        $instance = $this->_getOrThrow($id);
        $arrayContext = [
            'schema' => [
                'label_visibility' => ['type' => 'string'],
                'shortcodes' => ['type' => 'boolean'],
                'hidden' => ['type' => 'boolean'],
            ],
            'defaults' => [
                'label_visibility' => 'hidden',
                'shortcodes' => false,
                'hidden' => false,
            ],
            'errors' => []
        ];
        $viewModeInfo = $this->viewModes($viewMode);

        if ($this->request->data()) {
            $validator = $this->FieldInstances->validator('viewMode');
            $instance->validateViewModeSettings($this->request->data(), $validator, $viewMode);
            $errors = $validator->errors($this->request->data(), false);

            if (empty($errors)) {
                $instance->accessible('*', true);
                $viewModes = $instance->get('view_modes');
                $viewModes[$viewMode] = array_merge($viewModes[$viewMode], $this->request->data());
                $instance->set('view_modes', $viewModes);

                if ($this->FieldInstances->save($instance)) {
                    $this->Flash->success(__d('field', 'Field information was saved.'));
                    $this->redirect($this->referer());
                } else {
                    $this->Flash->danger(__d('field', 'Your information could not be saved.'));
                }
            } else {
                $this->Flash->danger(__d('field', 'View mode settings could not be saved.'));
                foreach ($errors as $field => $message) {
                    $arrayContext['errors'][$field] = $message;
                }
            }
        } else {
            $arrayContext['defaults'] = (array)$instance->view_modes[$viewMode];
            $this->request->data = $arrayContext['defaults'];
        }

        $this->title(__d('field', 'Configure View Mode'));
        $instance->accessible('settings', true);
        $this->set(compact('arrayContext', 'viewMode', 'viewModeInfo', 'instance'));
    }
public function viewModeEdit ( $ viewMode , $ id ) { $ this -> _validateViewMode ( $ viewMode ) ; $ instance = $ this -> _getOrThrow ( $ id ) ; $ arrayContext = [ 'schema' => [ 'label_visibility' => [ 'type' => 'string' ] , 'shortcodes' => [ 'type' => 'boolean' ] , 'hidden' => [ 'type' => 'boolean' ] , ] , 'defaults' => [ 'label_visibility' => 'hidden' , 'shortcodes' => false , 'hidden' => false , ] , 'errors' => [ ] ] ; $ viewModeInfo = $ this -> viewModes ( $ viewMode ) ; if ( $ this -> request -> data ( ) ) { $ validator = $ this -> FieldInstances -> validator ( 'viewMode' ) ; $ instance -> validateViewModeSettings ( $ this -> request -> data ( ) , $ validator , $ viewMode ) ; $ errors = $ validator -> errors ( $ this -> request -> data ( ) , false ) ; if ( empty ( $ errors ) ) { $ instance -> accessible ( '*' , true ) ; $ viewModes = $ instance -> get ( 'view_modes' ) ; $ viewModes [ $ viewMode ] = array_merge ( $ viewModes [ $ viewMode ] , $ this -> request -> data ( ) ) ; $ instance -> set ( 'view_modes' , $ viewModes ) ; if ( $ this -> FieldInstances -> save ( $ instance ) ) { $ this -> Flash -> success ( __d ( 'field' , 'Field information was saved.' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> danger ( __d ( 'field' , 'Your information could not be saved.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'field' , 'View mode settings could not be saved.' ) ) ; foreach ( $ errors as $ field => $ message ) { $ arrayContext [ 'errors' ] [ $ field ] = $ message ; } } } else { $ arrayContext [ 'defaults' ] = ( array ) $ instance -> view_modes [ $ viewMode ] ; $ this -> request -> data = $ arrayContext [ 'defaults' ] ; } $ this -> title ( __d ( 'field' , 'Configure View Mode' ) ) ; $ instance -> accessible ( 'settings' , true ) ; $ this -> set ( compact ( 'arrayContext' , 'viewMode' , 'viewModeInfo' , 'instance' ) ) ; }
Handles field instance rendering settings for a particular view mode.

@param string $viewMode View mode slug
@param int $id The field instance ID to manage
@return void
@throws \Cake\ORM\Exception\RecordNotFoundException When no field
instance was found
@throws \Cake\Network\Exception\NotFoundException When given view
mode does not exists
Handles field instance rendering settings for a particular view mode .