Open mortensassi opened 4 years ago
You can do this when you set up addRelationship.
class AttachmentProject extends Partial
{
public function fields()
{
$attachmentProject = new FieldsBuilder('attachment_project');
$attachmentProject
->addRelationship('project', [
'post_type' => 'project',
'acfe_bidirectional' => [
'acfe_bidirectional_enabled' => true,
'acfe_bidirectional_related' => [
'field_project_attachment',
],
],
]);
return $attachmentProject;
}
}
class ProjectAttachment extends Partial
{
public function fields()
{
$projectAttachment = new FieldsBuilder('project_attachment');
$projectAttachment
->addRelationship('attachment', [
'post_type' => 'attachment',
'acfe_bidirectional' => array(
'acfe_bidirectional_enabled' => true,
'acfe_bidirectional_related' => [
'field_attachment_project',
],
),
]);
return $projectAttachment;
}
}
When referencing the other field to link, the name is field_
plus whatever you've named the other field's FieldsBuilder
instance (not sure why it takes that name rather than the relationship field name). Or you can get the field name from looking at the admin area in the web inspector.
When i used ACF tohether ACF-Extended i really enjoyed having the "Bidirectional Field" Option on relatinship fields - Is it possible to implement such functionality to this plugin? Would love to hear your thoughts. (And sorry for being so ignorant and not submitting my own solution)