framework icon indicating copy to clipboard operation
framework copied to clipboard

Metabox body stays empty in editor

Open mvdhoek1 opened this issue 5 years ago • 8 comments

  • 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();
}

}`

mvdhoek1 avatar Dec 25 '19 14:12 mvdhoek1

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

Schermafbeelding 2020-01-18 om 15 48 33

mvdhoek1 avatar Jan 18 '20 14:01 mvdhoek1

@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 avatar Jan 21 '20 14:01 jlambe

@jlambe no problem, thanks for checking!

mvdhoek1 avatar Jan 21 '20 18:01 mvdhoek1

@jlambe is there an update by any chance?

mvdhoek1 avatar Jan 29 '20 09:01 mvdhoek1

Since there is no reaction yet I'll code the metaboxes in the Wordpress way myself.

mvdhoek1 avatar May 14 '20 07:05 mvdhoek1

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.

jlambe avatar May 15 '20 16:05 jlambe

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.

englertibor avatar Sep 26 '20 11:09 englertibor

Having the same issue.

  • WordPress v 6.31
  • Themosis v3.1
  • PHP v8.2.8

tophermurphy avatar Sep 08 '23 18:09 tophermurphy