code/control/KapostAdmin.php
public function getEditForm($id=null, $fields=null) {
        $form=parent::getEditForm($id, $fields);
        
        Requirements::css(KAPOST_DIR.'/css/KapostAdmin.css');
        Requirements::javascript(KAPOST_DIR.'/javascript/KapostAdmin.js');
        
        
        if($this->modelClass=='KapostObject' && $gridField=$form->Fields()->dataFieldByName('KapostObject')) {
            $gridField->setList($gridField->getList()->filter('IsKapostPreview', 0));
            $gridField->getConfig()
                                ->addComponent(new KapostGridFieldRefreshButton('before'))
                                ->removeComponentsByType('GridFieldAddNewButton')
                                ->getComponentByType('GridFieldDataColumns')
                                    ->setFieldCasting(array(
                                                            'Created'=>'SS_Datetime->FormatFromSettings',
                                                            'KapostChangeType'=>'KapostFieldCaster->NiceChangeType',
                                                            'ToPublish'=>'KapostFieldCaster->NiceToPublish'
                                                        ));
            
            $gridField->getConfig()
                                ->getComponentByType('GridFieldDetailForm')
                                    ->setItemRequestClass('KapostGridFieldDetailForm_ItemRequest');
        }else if($this->modelClass=='KapostConversionHistory' && $gridField=$form->Fields()->dataFieldByName('KapostConversionHistory')) {
            $gridField->getConfig()
                                ->removeComponentsByType('GridFieldAddNewButton')
                                ->addComponent(new KapostDestinationAction(), 'GridFieldEditButton');
            
            
            $dataColumns=$gridField->getConfig()->getComponentByType('GridFieldDataColumns');
            $dataColumns->setFieldCasting(array(
                                                'Created'=>'SS_Datetime->FormatFromSettings'
                                            ));
            
            $columns=$dataColumns->getDisplayFields($gridField);
            $columns['DestinationTypeNice']=_t('KapostConversionHistory.db_DestinationType', '_Destination Type');
            $columns['KapostChangeTypeNice']=_t('KapostConversionHistory.db_KapostChangeType', '_Change Type');
            $columns=$dataColumns->setDisplayFields($columns);
            
            
            $gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function(Form $form) {
                                                                                                            $form->addExtraClass('KapostAdmin');
                                                                                                        });
        }
        
        
        $form->addExtraClass('KapostAdmin');
        
        return $form;
    }
public function getEditForm($id=null, $fields=null) {
        $form=parent::getEditForm($id, $fields);
        
        Requirements::css(KAPOST_DIR.'/css/KapostAdmin.css');
        Requirements::javascript(KAPOST_DIR.'/javascript/KapostAdmin.js');
        
        
        if($this->modelClass=='KapostObject' && $gridField=$form->Fields()->dataFieldByName('KapostObject')) {
            $gridField->setList($gridField->getList()->filter('IsKapostPreview', 0));
            $gridField->getConfig()
                                ->addComponent(new KapostGridFieldRefreshButton('before'))
                                ->removeComponentsByType('GridFieldAddNewButton')
                                ->getComponentByType('GridFieldDataColumns')
                                    ->setFieldCasting(array(
                                                            'Created'=>'SS_Datetime->FormatFromSettings',
                                                            'KapostChangeType'=>'KapostFieldCaster->NiceChangeType',
                                                            'ToPublish'=>'KapostFieldCaster->NiceToPublish'
                                                        ));
            
            $gridField->getConfig()
                                ->getComponentByType('GridFieldDetailForm')
                                    ->setItemRequestClass('KapostGridFieldDetailForm_ItemRequest');
        }else if($this->modelClass=='KapostConversionHistory' && $gridField=$form->Fields()->dataFieldByName('KapostConversionHistory')) {
            $gridField->getConfig()
                                ->removeComponentsByType('GridFieldAddNewButton')
                                ->addComponent(new KapostDestinationAction(), 'GridFieldEditButton');
            
            
            $dataColumns=$gridField->getConfig()->getComponentByType('GridFieldDataColumns');
            $dataColumns->setFieldCasting(array(
                                                'Created'=>'SS_Datetime->FormatFromSettings'
                                            ));
            
            $columns=$dataColumns->getDisplayFields($gridField);
            $columns['DestinationTypeNice']=_t('KapostConversionHistory.db_DestinationType', '_Destination Type');
            $columns['KapostChangeTypeNice']=_t('KapostConversionHistory.db_KapostChangeType', '_Change Type');
            $columns=$dataColumns->setDisplayFields($columns);
            
            
            $gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function(Form $form) {
                                                                                                            $form->addExtraClass('KapostAdmin');
                                                                                                        });
        }
        
        
        $form->addExtraClass('KapostAdmin');
        
        return $form;
    }
public function getEditForm ( $ id = null , $ fields = null ) { $ form = parent :: getEditForm ( $ id , $ fields ) ; Requirements :: css ( KAPOST_DIR . '/css/KapostAdmin.css' ) ; Requirements :: javascript ( KAPOST_DIR . '/javascript/KapostAdmin.js' ) ; if ( $ this -> modelClass == 'KapostObject' && $ gridField = $ form -> Fields ( ) -> dataFieldByName ( 'KapostObject' ) ) { $ gridField -> setList ( $ gridField -> getList ( ) -> filter ( 'IsKapostPreview' , 0 ) ) ; $ gridField -> getConfig ( ) -> addComponent ( new KapostGridFieldRefreshButton ( 'before' ) ) -> removeComponentsByType ( 'GridFieldAddNewButton' ) -> getComponentByType ( 'GridFieldDataColumns' ) -> setFieldCasting ( array ( 'Created' => 'SS_Datetime->FormatFromSettings' , 'KapostChangeType' => 'KapostFieldCaster->NiceChangeType' , 'ToPublish' => 'KapostFieldCaster->NiceToPublish' ) ) ; $ gridField -> getConfig ( ) -> getComponentByType ( 'GridFieldDetailForm' ) -> setItemRequestClass ( 'KapostGridFieldDetailForm_ItemRequest' ) ; } else if ( $ this -> modelClass == 'KapostConversionHistory' && $ gridField = $ form -> Fields ( ) -> dataFieldByName ( 'KapostConversionHistory' ) ) { $ gridField -> getConfig ( ) -> removeComponentsByType ( 'GridFieldAddNewButton' ) -> addComponent ( new KapostDestinationAction ( ) , 'GridFieldEditButton' ) ; $ dataColumns = $ gridField -> getConfig ( ) -> getComponentByType ( 'GridFieldDataColumns' ) ; $ dataColumns -> setFieldCasting ( array ( 'Created' => 'SS_Datetime->FormatFromSettings' ) ) ; $ columns = $ dataColumns -> getDisplayFields ( $ gridField ) ; $ columns [ 'DestinationTypeNice' ] = _t ( 'KapostConversionHistory.db_DestinationType' , '_Destination Type' ) ; $ columns [ 'KapostChangeTypeNice' ] = _t ( 'KapostConversionHistory.db_KapostChangeType' , '_Change Type' ) ; $ columns = $ dataColumns -> setDisplayFields ( $ columns ) ; $ gridField -> getConfig ( ) -> getComponentByType ( 'GridFieldDetailForm' ) -> setItemEditFormCallback ( function ( Form $ form ) { $ form -> addExtraClass ( 'KapostAdmin' ) ; } ) ; } $ form -> addExtraClass ( 'KapostAdmin' ) ; return $ form ; }
Form used for displaying the gridfield in the model admin
@param string $id ID of the form
@param FieldList $fields Fields to use in the form
@return Form Form to be used in the model admin interface
Form used for displaying the gridfield in the model admin