framework
framework copied to clipboard
Metabox body stays empty in editor
- Themosis Version: 2.0.5
- WordPress Version: 5.2.3
- PHP Version: 7.2.21
Description
I'm declaring 2 metaboxes for my CPT but in the editor the metabox body stays empty and only a save button is displayed.
Below the code that I use for registering my CPT.
`<?php
namespace App\Hooks;
use Themosis\Hook\Hookable; use Themosis\Support\Facades\PostType; use Themosis\Support\Facades\Taxonomy; use Themosis\Support\Facades\Metabox; use Themosis\Support\Facades\Field;
class Houses extends Hookable { public function register() { PostType::make('houses', 'Houses', 'House') ->setArguments([ 'public' => true, 'menu_position' => 50, 'supports' => ['title', 'editor', 'thumbnail', 'custom-fields'], 'query_var' => false, 'menu_icon' => 'dashicons-admin-home', 'show_in_rest' => true, ]) ->set();
Taxonomy::make('house-category', 'houses', 'Categories', 'Category')
->set([
'public' => true,
'rewrite' => false,
'query_var' => false,
'hierarchical' => false
]);
Taxonomy::make('house-status', 'houses', 'Statusses', 'Status')
->set([
'public' => true,
'rewrite' => false,
'query_var' => false,
'hierarchical' => false
]);
Taxonomy::make('house-city', 'houses', 'Cities', 'City')
->set([
'public' => true,
'rewrite' => false,
'query_var' => false,
'hierarchical' => false
]);
Metabox::make('house-adress', 'houses')
->setTitle(_x('Adress', 'metabox', config('app.text_domain')))
->setPrefix('hs_')
->setContext('side')
->add(Field::text('street'))
->add(Field::text('housenumber'))
->add(Field::text('zipcode'))
->add(Field::text('city'))
->setPriority('high')
->set();
Metabox::make('house-information', 'houses')
->setTitle(_x('Information', 'metabox', config('app.text_domain')))
->setPrefix('hs_')
->setContext('side')
->add(Field::text('number_of_rooms'))
->add(Field::number('bid_price'))
->add(Field::number('asking_price'))
->set();
}
}`
I've found a Javascript error in de console log. themosis.core.js?ver=2.0.5:formatted:43692 TypeError: Cannot read property 'data' of undefined at themosis.core.js?ver=2.0.5:formatted:43687

@mvdhoek1 Sorry for the late response, quite busy at this time. Thanks for reporting this issue, I'm going to check this as soon as possible.
@jlambe no problem, thanks for checking!
@jlambe is there an update by any chance?
Since there is no reaction yet I'll code the metaboxes in the Wordpress way myself.
From a fresh installation, there is currently no issue with this, at least by defining a custom post type and multiple metaboxes.
The only issue on your code is the declaration of your taxonomies that use old framework methods/syntax. Please check the Taxonomy documentation for details.
I had a similar problem with metaboxes using themosis 2.0.7. After an investigation, I found out that when rendering themosisGlobal object in admin_head action, the filter "themosis_admin_global" from Metabox class isn't registered yet. After changing the "admin_head" to "admin_footer" in Application.php hook, the fields in metaboxes started to render.
Having the same issue.
- WordPress v 6.31
- Themosis v3.1
- PHP v8.2.8