Closed ivandotv closed 8 years ago
That's strange.
Can you check if you get the same problem in the loader plugin admin page accessed via Dashboard -> Admin Page Framework -> Help -> Report? That page has setting fields and also a page meta box.
Yes, metabox is in top right.
Try this code: I still can't make the metabox go to top right, maybe I'm doing somethign wrong, or it might be some kind of CSS issue.
class iki_MainThemeOptions extends AdminPageFramework {
public function setUp() {
$this->setRootMenuPage(
'Theme Options'
);
$this->addSubMenuItems(
array(
'title' => 'Global Options',
'page_slug' => 'iki_global_options',
), array(
'title' => 'Second Global',
'page_slug' => 'iki_other_options',
) );
$this->addSettingSections(
'iki_global_options',
array(
'section_id' => 'my_first_section',
'title' => 'My First Form Section',
'description' => 'This section is for text fields.',
),
array(
'section_id' => 'my_second_section',
'title' => 'My Second Form Section',
'description' => 'This section is for selectors.',
)
);
$this->addSettingFields(
'my_first_section', // target page slug
array(
'field_id' => 'my_color',
'type' => 'color',
'title' => 'Color',
'repeatable' => true,
'sortable' => true,
),
array(
'field_id' => 'my_image',
'type' => 'image',
'title' => 'Image',
'repeatable' => true,
'sortable' => true,
'attributes' => array(
'style' => 'max-width: 300px;',
)
)
);
$this->addSettingFields(
'my_second_section', // target page slug
array(
'field_id' => 'my_color',
'type' => 'color',
'title' => 'Color',
'repeatable' => true,
'sortable' => true,
),
array(
'field_id' => 'my_image',
'type' => 'image',
'title' => 'Image',
'repeatable' => true,
'sortable' => true,
'attributes' => array(
'style' => 'max-width: 300px;',
)
)
);
}
}
new iki_MainThemeOptions();
and for metboxes
class APF_Tutorial_SidePageMetaBox extends AdminPageFramework_MetaBox_Page {
}
new APF_Tutorial_SidePageMetaBox(
null, // meta box id - passing null will make it auto generate
__( 'Side Page Meta Box', 'admin-page-framework-tutorial' ), // title
'iki_global_options',
'normal', // context
'default' // priority
);
It seems there is a bug in the framework core introduced in v3.5.5 that you can no longer able to add form fields without an in-page tab. This will be fixed in the next release. So for the time being, can you try to put form fields in in-page tabs?
And let me know if that does not solve this problem. Sorry for the inconvenience.
No problem.
It seems the dev version has a problem. If you are using it, can you go back to the stable version and see if the problem goes away?
To check the included library version, you can find it by moving your mouse over the footer link named Admin Page Framework in the created admin page.
I just noticed that you need to set side
to the context parameter.
new APF_Tutorial_SidePageMetaBox(
null, // meta box id - passing null will make it auto generate
__( 'Side Page Meta Box', 'admin-page-framework-tutorial' ), // title
'iki_global_options',
'side', // context <--- this one!
'default' // priority
);
Let me know if this fixes your problem.
By the way, the dev branch has been updated and it fixes an issue of adding form fields without in-page tabs. Also never mind what I said that a bug was introduced in v3.5.5. That wasn't the case. The dev branch had an issue of loading incorrect files.
I've tried with side
, it's not in the code I posted previously, put I've tried all three valid options.
Okay, I could confirm this problem finally when no side
meta box exists and a normal
oradvanced
one gets added. I'll change the framework code to set 1
to the screen layout option when no side meta box exists.
Thanks for the report.
v3.6.5 has been released which includes this fix.
Referring to the tutorial 9 Add metabox in admin page I can't seem to move the metabox in to the main area. It always appears on the side,
context
property doesn't change anything. And if I introduce sections, then metabox is pushed down.