Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scoumbourdis/77956759bf25800f4580bb9475807954 to your computer and use it in GitHub Desktop.
Save scoumbourdis/77956759bf25800f4580bb9475807954 to your computer and use it in GitHub Desktop.
---
src/GroceryCrud/Core/State/StateAbstract.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/GroceryCrud/Core/State/StateAbstract.php b/src/GroceryCrud/Core/State/StateAbstract.php
index 6b37f87..c2c2424 100644
--- a/src/GroceryCrud/Core/State/StateAbstract.php
+++ b/src/GroceryCrud/Core/State/StateAbstract.php
@@ -1311,11 +1311,14 @@ class StateAbstract
public function getFieldTypesAddForm() {
$fieldTypesAddForm = $this->gCrud->getFieldTypesAddForm();
$callbackAddFields = $this->gCrud->getCallbackAddFields();
+ $fieldTypes = $this->getFieldTypes(false);
foreach ($callbackAddFields as $fieldName => $callback) {
+ $fieldType = array_key_exists($fieldName, $fieldTypes) ? $fieldTypes[$fieldName] : null;
+
$fieldTypeModel = new ModelFieldType();
$fieldTypeModel->dataType = GroceryCrud::FIELD_TYPE_BACKEND_CALLBACK;
- $fieldTypeModel->defaultValue = $callback();
+ $fieldTypeModel->defaultValue = $callback($fieldType, $fieldName);
$fieldTypesAddForm[$fieldName] = $fieldTypeModel;
}
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment