• Resolved ToTTi

    (@formgarten)


    I stick to the example with author and books. In my case, the Relationship field allows me to assign several books to an author on the authors page, but a book can only be assigned to ONE author on the book page (also through out a relationship field). Example: I have assigned author 1 the book 1 – now if I assign the author 2 also the book 1, from my understanding book 1 should only be assigned to author 2 anymore. Then the previous author 1 should no more be seen as assigned on the book page. If that’s exactly what the overwrite settings should do, it will not work for me, even though I’ve stuck to all the guidelines: same key_name etc. In my example from above, according to the scenario described, on the book page both authors 1 and 2 are assigned. Was that understandable? :))

    Or didn’t I understand correctly what the overwrite settings does? The code I used (I also checked the copy paste code):

    add_filter('acf-post2post/overwrite-settings', 'my_overwrite_settings');
    function my_overwrite_settings($settings) {
      $settings['orte2partner'] = array(
        'overwrite' => true,
        'type' => 'first'
      );
      return $settings;
    }
    • This topic was modified 6 years, 4 months ago by ToTTi.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author John Huebner

    (@hube2)

    Please provide the PHP export of the field(s) you are setting up for this relationship so I can understand what might be happening. Please, just the field(s) and not the entire group(s).

    Thread Starter ToTTi

    (@formgarten)

    Don’t know what you mean with PHP export of the field(s). How (and) can I do such an export? You want to see my ACF field setup of that relationship field?

    Plugin Author John Huebner

    (@hube2)

    Yes, go to ACF => Tools. Export your field definition and copy the code for the fields in question. Seeing the field definitions will give me all the information I need and much easier than trying to explain it all. You should have 2 fields in this case because one field should allow multiple selections while the other field should only allow 1 selection.

    Thread Starter ToTTi

    (@formgarten)

    Okay, thank you. I hope that’s what you’re looking for:

    acf_add_local_field_group(array(
    	'key' => 'group_5d88e00098e9d',
    	'title' => 'Partner - Weitere Angaben',
    	'fields' => array(
    		array(
    			'key' => 'field_5da068c2eacb4',
    			'label' => 'Orte2Partner',
    			'name' => 'orte2partner',
    			'type' => 'relationship',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'post_type' => array(
    				0 => 'orte',
    			),
    			'taxonomy' => '',
    			'filters' => array(
    				0 => 'search',
    			),
    			'elements' => array(
    				0 => 'featured_image',
    			),
    			'min' => '',
    			'max' => 1,
    			'return_format' => 'object',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'partner',
    			),
    		),
    	),
    ));
    
    acf_add_local_field_group(array(
    	'key' => 'group_5d88d04c06128',
    	'title' => 'Weitere Angaben des Ortes',
    	'fields' => array(
    				array(
    			'key' => 'field_5da0684de31b9',
    			'label' => 'Orte2Partner',
    			'name' => 'orte2partner',
    			'type' => 'relationship',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'post_type' => array(
    				0 => 'partner',
    			),
    			'taxonomy' => '',
    			'filters' => array(
    				0 => 'search',
    			),
    			'elements' => array(
    				0 => 'featured_image',
    			),
    			'min' => '',
    			'max' => '',
    			'return_format' => 'object',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'orte',
    			),
    		),
    	),
    ));
    
    Plugin Author John Huebner

    (@hube2)

    I’ll have to do some testing, might be a recent change in ACF causing problems cuz I don’t see anything wrong with what you have just by looking.

    Thread Starter ToTTi

    (@formgarten)

    I hope you’ll find the reason 😉

    Plugin Author John Huebner

    (@hube2)

    There was an error in the overwrite logic. I just pushed an updated version that should correct it.

    Thread Starter ToTTi

    (@formgarten)

    Great!! Thank you!! 👌 Works perfectly with inline editing of Admin Columns Pro also …

    • This reply was modified 6 years, 4 months ago by ToTTi.
Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Problem with provided overwrite setting’ is closed to new replies.