From c234e1363bc92864da16bf0829fc37ea096f3f06 Mon Sep 17 00:00:00 2001 From: GreenBlueRup Date: Thu, 19 Apr 2018 11:43:37 +0200 Subject: [PATCH 1/3] Added option to load custom fields Added an option to load custom fields from external plugins --- services/AmForms_FieldsService.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/services/AmForms_FieldsService.php b/services/AmForms_FieldsService.php index 4ffef3c..c3bd152 100644 --- a/services/AmForms_FieldsService.php +++ b/services/AmForms_FieldsService.php @@ -46,7 +46,7 @@ public function getProperFieldTypes($fieldTypes) return $fieldTypeGroups; } - + /** * Get supported field types. * @@ -54,7 +54,7 @@ public function getProperFieldTypes($fieldTypes) */ public function getSupportedFieldTypes() { - return array( + $supportedFields = array( 'AmForms_Hidden', 'Assets', 'Checkboxes', @@ -66,5 +66,24 @@ public function getSupportedFieldTypes() 'RadioButtons', 'AmForms_Email', ); + + return array_merge($supportedFields, $this->getCustomFieldTypes()); + } + + /** + * Get custom field types. + * + * @return array + */ + public function getCustomFieldTypes() + { + $customFieldTypes = []; + + foreach (craft()->plugins->call('amFormsCustomField') as $customFieldType) { + /* something happens here */ + $customFieldTypes[] = $customFieldType; + } + + return array_merge($customFieldTypes); } } From 45f8ff377255e390c814e74e8f56ffdf43cc51b2 Mon Sep 17 00:00:00 2001 From: GreenBlueRup Date: Thu, 19 Apr 2018 11:44:27 +0200 Subject: [PATCH 2/3] Removed whitespace --- services/AmForms_FieldsService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/AmForms_FieldsService.php b/services/AmForms_FieldsService.php index c3bd152..38a094d 100644 --- a/services/AmForms_FieldsService.php +++ b/services/AmForms_FieldsService.php @@ -46,7 +46,7 @@ public function getProperFieldTypes($fieldTypes) return $fieldTypeGroups; } - + /** * Get supported field types. * From 001840876b09ca47b84a0181d7dd5c1ad68b2544 Mon Sep 17 00:00:00 2001 From: GreenBlueRup Date: Thu, 19 Apr 2018 12:01:40 +0200 Subject: [PATCH 3/3] Added the option to use arrays instead of strings removed unnecessary array_merge() --- services/AmForms_FieldsService.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/AmForms_FieldsService.php b/services/AmForms_FieldsService.php index 38a094d..e3d734a 100644 --- a/services/AmForms_FieldsService.php +++ b/services/AmForms_FieldsService.php @@ -79,11 +79,12 @@ public function getCustomFieldTypes() { $customFieldTypes = []; - foreach (craft()->plugins->call('amFormsCustomField') as $customFieldType) { - /* something happens here */ - $customFieldTypes[] = $customFieldType; + foreach (craft()->plugins->call('amFormsCustomFields') as $customFieldTypes) { + foreach ($customFieldTypes as $customFieldType) { + $customFieldTypes[] = $customFieldType; + } } - return array_merge($customFieldTypes); + return $customFieldTypes; } }