public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);
        if ($this->modelClass == Order::class) {
            /** @var GridFieldConfig $config */
            $config = $form
                ->Fields()
                ->fieldByName($this->sanitiseClassName($this->modelClass))
                ->getConfig();

            $config
                ->getComponentByType(GridFieldSortableHeader::class)
                ->setFieldSorting([ 'StatusI18N' => 'Status' ]);

            $config
                ->getComponentByType(GridFieldDetailForm::class)
                ->setItemRequestClass(OrderGridFieldDetailForm_ItemRequest::class); //see below
        }

        if ($this->modelClass == OrderStatusLog::class) {
            /** @var GridFieldConfig $config */
            $config = $form
                ->Fields()
                ->fieldByName($this->sanitiseClassName($this->modelClass))
                ->getConfig();

            // Remove add new button
            $config->removeComponentsByType($config->getComponentByType(GridFieldAddNewButton::class));
        }

        return $form;
    }
public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);
        if ($this->modelClass == Order::class) {
            /** @var GridFieldConfig $config */
            $config = $form
                ->Fields()
                ->fieldByName($this->sanitiseClassName($this->modelClass))
                ->getConfig();

            $config
                ->getComponentByType(GridFieldSortableHeader::class)
                ->setFieldSorting([ 'StatusI18N' => 'Status' ]);

            $config
                ->getComponentByType(GridFieldDetailForm::class)
                ->setItemRequestClass(OrderGridFieldDetailForm_ItemRequest::class); //see below
        }

        if ($this->modelClass == OrderStatusLog::class) {
            /** @var GridFieldConfig $config */
            $config = $form
                ->Fields()
                ->fieldByName($this->sanitiseClassName($this->modelClass))
                ->getConfig();

            // Remove add new button
            $config->removeComponentsByType($config->getComponentByType(GridFieldAddNewButton::class));
        }

        return $form;
    }
public function getEditForm ( $ id = null , $ fields = null ) { $ form = parent :: getEditForm ( $ id , $ fields ) ; if ( $ this -> modelClass == Order :: class ) { /** @var GridFieldConfig $config */ $ config = $ form -> Fields ( ) -> fieldByName ( $ this -> sanitiseClassName ( $ this -> modelClass ) ) -> getConfig ( ) ; $ config -> getComponentByType ( GridFieldSortableHeader :: class ) -> setFieldSorting ( [ 'StatusI18N' => 'Status' ] ) ; $ config -> getComponentByType ( GridFieldDetailForm :: class ) -> setItemRequestClass ( OrderGridFieldDetailForm_ItemRequest :: class ) ; //see below } if ( $ this -> modelClass == OrderStatusLog :: class ) { /** @var GridFieldConfig $config */ $ config = $ form -> Fields ( ) -> fieldByName ( $ this -> sanitiseClassName ( $ this -> modelClass ) ) -> getConfig ( ) ; // Remove add new button $ config -> removeComponentsByType ( $ config -> getComponentByType ( GridFieldAddNewButton :: class ) ) ; } return $ form ; }
Replace gridfield detail form to include print functionality
Replace gridfield detail form to include print functionality