2525 * Form Field class for the Joomla Platform.
2626 * Supports a generic list of options.
2727 *
28- * @since 1.7.0
28+ * @since __DEPLOY_VERSION__
2929 */
3030
3131class OpengraphField extends GroupedlistField
@@ -34,7 +34,7 @@ class OpengraphField extends GroupedlistField
3434 * The form field type.
3535 *
3636 * @var string
37- * @since 1.7.0
37+ * @since __DEPLOY_VERSION__
3838 */
3939 protected $ type = 'Opengraph ' ;
4040
@@ -44,7 +44,7 @@ class OpengraphField extends GroupedlistField
4444 *
4545 * @return object[] The field option objects.
4646 *
47- * @since 3.7.0
47+ * @since __DEPLOY_VERSION__
4848 */
4949 protected function getGroups ()
5050 {
@@ -81,19 +81,27 @@ protected function getGroups()
8181 return $ groups ;
8282 }
8383
84- $ customOptions = [];
84+ // Allowed field types for each OpenGraph group
85+ $ allowedFieldTypes = [
86+ 'text-fields ' => ['text ' , 'textarea ' ],
87+ 'image-fields ' => ['media ' , 'imagelist ' ],
88+ 'image-alt-fields ' => ['text ' ],
89+ ];
8590
91+ $ allowedTypes = $ allowedFieldTypes [$ fieldType ] ?? [];
8692
8793 $ customFields = FieldsHelper::getFields ('com_content.article ' , null );
94+ $ customOptions = [];
8895
8996 foreach ($ customFields as $ field ) {
90- // todo : will be filtered by type or group in the future
97+ if (!in_array ($ field ->type , $ allowedTypes , true )) {
98+ continue ;
99+ }
91100
92101 $ label = $ field ->title . ' ( ' . $ field ->name . ') ' ;
93- $ customOptions [] = HTMLHelper::_ ('select.option ' , $ field ->name , $ label );
102+ $ customOptions [] = HTMLHelper::_ ('select.option ' , ' field. ' . $ field ->name , $ label );
94103 }
95104
96-
97105 if (!empty ($ customOptions )) {
98106 $ groups ['Custom Fields ' ] = $ customOptions ;
99107 }
0 commit comments