diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..91ce0e0
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/silverstripe-blog.iml b/.idea/silverstripe-blog.iml
new file mode 100644
index 0000000..c179ff9
--- /dev/null
+++ b/.idea/silverstripe-blog.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..ad793fd
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $PROJECT_DIR$/composer.json
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ _t(
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1561930166221
+
+
+ 1561930166221
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Forms/GridField/GridFieldAddByDBField.php b/src/Forms/GridField/GridFieldAddByDBField.php
index 6c4e73b..7a4b06f 100644
--- a/src/Forms/GridField/GridFieldAddByDBField.php
+++ b/src/Forms/GridField/GridFieldAddByDBField.php
@@ -37,6 +37,13 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
*/
protected $dataObjectField = 'Title';
+ /**
+ * Name for the buttons displayed in the CMS
+ *
+ * @var string
+ */
+ protected $buttonName;
+
/**
* Creates a text field and add button which allows the user to directly create a new
* DataObject by just entering the title.
@@ -142,6 +149,19 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
return $this->dataObjectField;
}
+ /**
+ * Set the button name
+ *
+ * @param $name
+ * @return $this
+ */
+ public function setButtonName($name)
+ {
+ $this->buttonName = $name;
+
+ return $this;
+ }
+
/**
* Set the database field.
*
@@ -188,14 +208,20 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
->setAttribute('placeholder', $obj->fieldLabel($dbField))
->addExtraClass('no-change-track');
+ if (!$this->buttonName) {
+ // provide a default button name, can be changed by calling {@link setButtonName()} on this component
+ $objectName = $obj->i18n_singular_name();
+ $this->buttonName = _t(__CLASS__ . '.ButtonName', 'Add {name}', array('name' => $objectName));
+ }
+
$addAction = GridField_FormAction::create(
$gridField,
'add',
_t(
__CLASS__ . '.Add',
- 'Add {name}',
+ '{name}',
'Add button text',
- ['name' => $obj->i18n_singular_name()]
+ ['name' => $this->buttonName]
),
'add',
'add'