I’m trying to understand, And I see what I did wrong in my last example. So I tried starting only with a Field, and a partial. And instead of adding it to a block, I just added to post_type page. And the partial just wont show up inside the field. Only the empty field shows up without the field set in the partial. I don’t know what I am doing wrong here. I basically copy pasted code from the docs, and I only changed the ‘example’ to my own name.
See the attached image (and yes I did expand the fieldgroup.
My Field
<?php
namespace App\Fields\Partials;
use Log1x\AcfComposer\Partial;
use StoutLogic\AcfBuilder\FieldsBuilder;
class blockImageCaption extends Partial
{
/**
* The partial field group.
*
* @return \StoutLogic\AcfBuilder\FieldsBuilder
*/
public function fields()
{
$blockImageCaption = new FieldsBuilder('block_image_caption');
$blockImageCaption
->addImage(
'image',
[
'label' => 'Afbeelding',
'instructions' => 'Afbeelding met bijbehorende caption',
'required' => 1,
'return_format' => 'array',
'preview_size' => 'medium',
'library' => 'all',
]
);
return $blockImageCaption;
}
}
My Partial
<?php
namespace App\Fields;
use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldsBuilder;
class blockImage extends Field
{
/**
* The field group.
*
* @return array
*/
public function fields()
{
$blockImage = new FieldsBuilder('block_image');
$blockImage
->setLocation('post_type', '==', 'page');
$blockImage
->addFields($this->get(blockImageCaption::class));
return $blockImage->build();
}
}