code/forms/gridfield/GridFieldAddByDBField.php
public function getHTMLFragments($gridField) {
		$dataClass = $gridField->getList()->dataClass();
		$obj = singleton($dataClass);
		if(!$obj->canCreate()) return "";

		$dbField = $this->getDataObjectField();

		$textField = TextField::create(
			"gridfieldaddbydbfield[" . $obj->ClassName . "][" . Convert::raw2htmlatt($dbField) . "]"
			)->setAttribute("placeholder", $obj->fieldLabel($dbField))
			->addExtraClass("no-change-track");

		$addAction = new GridField_FormAction($gridField, 
			'add',
			_t('GridFieldAddByDBField.Add', 
				"Add {name}", "Add button text", 
				array("name" => $obj->i18n_singular_name())
			), 
			'add', 
			'add'
		);
		$addAction->setAttribute('data-icon', 'add');

		// Start thinking about rending this back to the GF
		$forTemplate = new ArrayData(array());
		$forTemplate->Fields = new ArrayList();

		$forTemplate->Fields->push($textField);
		$forTemplate->Fields->push($addAction);

		return array(
			$this->targetFragment => $forTemplate->renderWith("GridFieldAddByDBField")
		);
	}
public function getHTMLFragments($gridField) {
		$dataClass = $gridField->getList()->dataClass();
		$obj = singleton($dataClass);
		if(!$obj->canCreate()) return "";

		$dbField = $this->getDataObjectField();

		$textField = TextField::create(
			"gridfieldaddbydbfield[" . $obj->ClassName . "][" . Convert::raw2htmlatt($dbField) . "]"
			)->setAttribute("placeholder", $obj->fieldLabel($dbField))
			->addExtraClass("no-change-track");

		$addAction = new GridField_FormAction($gridField, 
			'add',
			_t('GridFieldAddByDBField.Add', 
				"Add {name}", "Add button text", 
				array("name" => $obj->i18n_singular_name())
			), 
			'add', 
			'add'
		);
		$addAction->setAttribute('data-icon', 'add');

		// Start thinking about rending this back to the GF
		$forTemplate = new ArrayData(array());
		$forTemplate->Fields = new ArrayList();

		$forTemplate->Fields->push($textField);
		$forTemplate->Fields->push($addAction);

		return array(
			$this->targetFragment => $forTemplate->renderWith("GridFieldAddByDBField")
		);
	}
public function getHTMLFragments ( $ gridField ) { $ dataClass = $ gridField -> getList ( ) -> dataClass ( ) ; $ obj = singleton ( $ dataClass ) ; if ( ! $ obj -> canCreate ( ) ) return "" ; $ dbField = $ this -> getDataObjectField ( ) ; $ textField = TextField :: create ( "gridfieldaddbydbfield[" . $ obj -> ClassName . "][" . Convert :: raw2htmlatt ( $ dbField ) . "]" ) -> setAttribute ( "placeholder" , $ obj -> fieldLabel ( $ dbField ) ) -> addExtraClass ( "no-change-track" ) ; $ addAction = new GridField_FormAction ( $ gridField , 'add' , _t ( 'GridFieldAddByDBField.Add' , "Add {name}" , "Add button text" , array ( "name" => $ obj -> i18n_singular_name ( ) ) ) , 'add' , 'add' ) ; $ addAction -> setAttribute ( 'data-icon' , 'add' ) ; // Start thinking about rending this back to the GF
 $ forTemplate = new ArrayData ( array ( ) ) ; $ forTemplate -> Fields = new ArrayList ( ) ; $ forTemplate -> Fields -> push ( $ textField ) ; $ forTemplate -> Fields -> push ( $ addAction ) ; return array ( $ this -> targetFragment => $ forTemplate -> renderWith ( "GridFieldAddByDBField" ) ) ; }
Renders the TextField and add button to the GridField.

@param $girdField GridField

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