public function getHTMLFragments($grid)
    {
        $dataClass = $grid->getList()->dataClass();
        $obj = singleton($dataClass);

        if (!$obj->canCreate()) {
            return "";
        }

        $text_field = TextField::create("gridfieldaddbydbfield")
            ->setAttribute(
                "placeholder",
                _t(
                    "GridFieldAddLineItem.TypeToAdd",
                    "Type to add by {Filters} or {Title}",
                    "Inform the user what to add based on",
                    [
                        "Filters" => implode(", ", $this->getFilterFields()),
                        "Title" => $this->getCreateField()
                    ]
                )
            )->addExtraClass("relation-search no-change-track")
            ->setAttribute(
                'data-search-url',
                Controller::join_links($grid->Link('search'))
            );

        $find_action = GridField_FormAction::create(
            $grid,
            'gridfield_relationfind',
            _t('GridField.Find', "Find"),
            'find',
            'find'
        );
        $find_action->setAttribute('data-icon', 'relationfind');

        $add_action = GridField_FormAction::create(
            $grid,
            'gridfield_lineitemadd',
            _t("GridFieldAddLineItem.Add", "Add"),
            'add',
            'add'
        );
        $add_action->addExtraClass('btn btn-primary font-icon-plus-circled');
        $add_action->addExtraClass('action_gridfield_relationadd');

        // Start thinking about rending this back to the GF
        $fields = ArrayList::create();

        $fields->push($text_field);
        $fields->push($find_action);
        $fields->push($add_action);

        $forTemplate = ArrayData::create([]);
        $forTemplate->Fields = $fields;

        return [
            $this->targetFragment => $forTemplate->renderWith(AddLineItem::class)
        ];
    }
public function getHTMLFragments($grid)
    {
        $dataClass = $grid->getList()->dataClass();
        $obj = singleton($dataClass);

        if (!$obj->canCreate()) {
            return "";
        }

        $text_field = TextField::create("gridfieldaddbydbfield")
            ->setAttribute(
                "placeholder",
                _t(
                    "GridFieldAddLineItem.TypeToAdd",
                    "Type to add by {Filters} or {Title}",
                    "Inform the user what to add based on",
                    [
                        "Filters" => implode(", ", $this->getFilterFields()),
                        "Title" => $this->getCreateField()
                    ]
                )
            )->addExtraClass("relation-search no-change-track")
            ->setAttribute(
                'data-search-url',
                Controller::join_links($grid->Link('search'))
            );

        $find_action = GridField_FormAction::create(
            $grid,
            'gridfield_relationfind',
            _t('GridField.Find', "Find"),
            'find',
            'find'
        );
        $find_action->setAttribute('data-icon', 'relationfind');

        $add_action = GridField_FormAction::create(
            $grid,
            'gridfield_lineitemadd',
            _t("GridFieldAddLineItem.Add", "Add"),
            'add',
            'add'
        );
        $add_action->addExtraClass('btn btn-primary font-icon-plus-circled');
        $add_action->addExtraClass('action_gridfield_relationadd');

        // Start thinking about rending this back to the GF
        $fields = ArrayList::create();

        $fields->push($text_field);
        $fields->push($find_action);
        $fields->push($add_action);

        $forTemplate = ArrayData::create([]);
        $forTemplate->Fields = $fields;

        return [
            $this->targetFragment => $forTemplate->renderWith(AddLineItem::class)
        ];
    }
public function getHTMLFragments ( $ grid ) { $ dataClass = $ grid -> getList ( ) -> dataClass ( ) ; $ obj = singleton ( $ dataClass ) ; if ( ! $ obj -> canCreate ( ) ) { return "" ; } $ text_field = TextField :: create ( "gridfieldaddbydbfield" ) -> setAttribute ( "placeholder" , _t ( "GridFieldAddLineItem.TypeToAdd" , "Type to add by {Filters} or {Title}" , "Inform the user what to add based on" , [ "Filters" => implode ( ", " , $ this -> getFilterFields ( ) ) , "Title" => $ this -> getCreateField ( ) ] ) ) -> addExtraClass ( "relation-search no-change-track" ) -> setAttribute ( 'data-search-url' , Controller :: join_links ( $ grid -> Link ( 'search' ) ) ) ; $ find_action = GridField_FormAction :: create ( $ grid , 'gridfield_relationfind' , _t ( 'GridField.Find' , "Find" ) , 'find' , 'find' ) ; $ find_action -> setAttribute ( 'data-icon' , 'relationfind' ) ; $ add_action = GridField_FormAction :: create ( $ grid , 'gridfield_lineitemadd' , _t ( "GridFieldAddLineItem.Add" , "Add" ) , 'add' , 'add' ) ; $ add_action -> addExtraClass ( 'btn btn-primary font-icon-plus-circled' ) ; $ add_action -> addExtraClass ( 'action_gridfield_relationadd' ) ; // Start thinking about rending this back to the GF $ fields = ArrayList :: create ( ) ; $ fields -> push ( $ text_field ) ; $ fields -> push ( $ find_action ) ; $ fields -> push ( $ add_action ) ; $ forTemplate = ArrayData :: create ( [ ] ) ; $ forTemplate -> Fields = $ fields ; return [ $ this -> targetFragment => $ forTemplate -> renderWith ( AddLineItem :: class ) ] ; }
Renders the TextField and add button to the GridField.

@param $girdField GridField

@return string HTML
Renders the TextField and add button to the GridField .