Closed Coders91 closed 2 months ago
Something like this should do the trick:
$company = Builder::make('company', [
'acfe_display_title' => 'Page Settings',
'position' => 'side',
]);
Thank you, doesn't seem to be working though. Full code:
namespace App\Fields;
use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Field;
class Sidebar extends Field
{
/**
* The field group.
*/
public function fields(): array
{
$sidebar = Builder::make('sidebar', [
'position' => 'side',
]);
$sidebar
->setLocation('post_type', '==', 'page');
$sidebar
->addSelect('select_field', [
'label' => 'Select Field',
'required' => 0,
'choices' => $this->sidebars(),
'default_value' => 'none',
'allow_null' => 1,
'multiple' => 0,
'ui' => 1,
'ajax' => 0,
'placeholder' => 'Select a sidebar',
]);
return $sidebar->build();
}
Hmm, have you ran acorn acf:cache
at any point? If so, you might need to clear it with acf:clear
– otherwise I'm not sure why this wouldn't be working. I have a project with a few fields in the sidebar of a custom post type and if I remove 'position' => 'side',
it moves it back to the bottom of the editor, and re-adding it is putting it back in the sidebar as intended. 😕
Removing the existing page and adding new one does put the field in the sidebar. Thank you for your quick support and everything we can use :).
Sorry but I really can't seem to find where to include the position for a created field group. I tried passing it in field class
$defaults = ['location' => 'side']
but this gives an errorType of App\Fields\Sidebar::$defaults must be Illuminate\Support\Collection|array (as in class Log1x\AcfComposer\Composer)
. Also tried guessing a method$sidebar->setPosition('side')
and$sidebar ->setGroupConfig('position', 'side');