Created
June 29, 2019 08:20
-
-
Save scoumbourdis/77956759bf25800f4580bb9475807954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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