michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Select2 on AdminPageFramework_MetaBox not found on 3.8.18 #278

Closed SUGO-es closed 5 years ago

SUGO-es commented 5 years ago

Type of issue

Steps to reproduce the issue (for Bug report)

  1. Change select to select2 field on wp-content\plugins\admin-page-framework\example\post_meta_box\APF_MetaBox_BuiltinFieldTypes.php

** ERROR:

Call stack:

do_meta_boxes() wp-admin/edit-form-advanced.php:714 gutenberg_override_meta_box_callback() wp-admin/includes/template.php:1073 AdminPageFramework_MetaBox_View->_replyToPrintMetaBoxContents() wp-content/plugins/gutenberg/lib/meta-box-partial-page.php:214 AdminPageFramework_Form_View->get() wp-content/plugins/admin-page-framework/library/apf/factory/meta_box/AdminPageFramework_MetaBox.php:122 AdminPageFramework_Form_View_Sectionsets->get() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/AdminPageFramework_Form.php:247 AdminPageFramework_FormViewSectionsets->_getFormOutput() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Sectionsets.php:27 AdminPageFramework_FormViewSectionsets->_getSectionsetsTables() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Sectionsets.php:41 AdminPageFramework_FormViewSectionsets->_getSectionsetTable() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Sectionsets.php:58 AdminPageFramework_FormViewSectionsets->_getSectionTableWithTabList() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Sectionsets.php:79 AdminPageFramework_FormViewSection->get() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Sectionsets.php:113 AdminPageFramework_FormViewSection->_getSectionContent() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Section.php:35 AdminPageFramework_FormViewFieldsetRows->get() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_Section.php:44 AdminPageFramework_FormViewFieldsetRows->_getFieldsetRow() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_FieldsetRows.php:34 AdminPageFramework_FormViewFieldsetTableRow->get() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_FieldsetRows.php:40 AdminPageFramework_FormViewFieldsetTableRow->_getFieldByContainer() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_FieldsetRow.php:29 AdminPageFramework_FormViewSection_Base->getFieldsetOutput() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_FieldsetRow.php:38 AdminPageFramework_FormViewFieldset->get() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/sectionset/AdminPageFramework_Form_View_CollapsibleSectionTitle.php:25 AdminPageFramework_FormViewFieldset->_getFieldsOutput() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/fieldset/AdminPageFramework_Form_View_Fieldset.php:125 AdminPageFramework_FormViewFieldset->_getEachFieldOutput() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/fieldset/AdminPageFramework_Form_View_Fieldset.php:131 AdminPageFramework_FieldType_default->_replyToGetField() wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/_view/fieldset/AdminPageFramework_FormViewFieldset.php:142 wp-content/plugins/admin-page-framework/library/apf/factory/_common/form/field_type/AdminPageFramework_FieldType_default.php:10

I tried to find the point of error within the calls, but it escapes my knowledge, i think it can be in:

AdminPageFramework_Form_View___Fieldset->_getEachFieldOutput()

Currently in the local I have working the plugin APF and two copies in two other plugins with my_plugin1_AdminPageFramework and My_plugin2_AdminPageFramework working without any other problem.

In one of the plugins when trying to put a select2 field in a metabox gave me this error, the easiest way to reproduce it is by following the steps described above in the APF base plugin.

If you need any more information, request it.

Best regards.

michaeluno commented 5 years ago

Hello,

Can you post the error message, not the call stack? Or you can post the screenshot.

By the way, the steps you wrote indicate that you did not register the select2 custom field type.

SUGO-es commented 5 years ago

Sorry MichaelUno,

Type: Notice Message: Array to string conversion Count: 1 Location: content/plugins/admin-page-framework/library/apf/factory/_common/form/field_type/AdminPageFramework_FieldType_default.php:10

By the way, the steps you wrote indicate that you did not register the select2 custom field type. <

yes, the problem is there, it's as if in the metadox the custom fields will not load correctly, at some point you pass a string string as an array and take the value of some normal field.

I am creating a small plugin to reproduce the error, if you do not find the error before I finish the plugin I will upload it here so you can check.

As always, thank you very much for your support and for this great framework.

best regards.

SUGO-es commented 5 years ago

APF-error-MB-custom-fields.zip

I have added a small plugin that reproduces the problem.

Inherit from APF plugin and its custom fields, I hope it helps.

It happens when you try to put custom fields in metabox, it does not matter if they are in a custom post or in a normal page.

Sorry for my English, I'm translating with Google.

michaeluno commented 5 years ago

You want to register the custom field type. Try inserting this code in your extended class.

    public function load() {
        // Register custom field types - you need to do this for every class extending the framework factory class
        new Select2CustomFieldType( get_class( $this ) );
    }

This is mentioned in:

For your compiled framework versions, you need to add your prefix to the class name like MyPlugin_Select2CustomFieldType( get_class( $this ) ). And you need to check Select2 when generating the download files.

SUGO-es commented 5 years ago

Hi Micheluno,

Everything that you explain to me is clear to me, I did it at the time when I created my extended class and those steps are in place.

The only thing I did not take into account was get_class ($ this), I have corrected it both in my plugins and in the small plugin that I have uploaded here.

The problem remains unresolved, I invite you to download the small plugin that I have uploaded and play a little with it, you will immediately understand the problem.

image

Thank you very much for your patience and attention.

Best regards.

michaeluno commented 5 years ago

I checked your plugin and you forgot to register the custom field types for the APF_Error_MB_CF_CustomPostTypeMetaBox class (metabox.php) in your example plugin.

SUGO-es commented 5 years ago

Hi Micheluno,

Yes, registering the custom field in the load "in each metabox" event already works.

I thought that adding them to the framwork in the load would be enough for all APF.

This should not be like that?

Thank you very much for your clarification and patience.

Best regards.

michaeluno commented 5 years ago

No.