Tell us what you are trying to do?
I have a relationship form which I use to edit a relationship. In this form I try to preselect a value in an intermediary custom field, that is different from the value, that was previously saved, when the relationship was created.
Example:
When the relationship is created, the intermediary custom firld should save 'no'
In the edit form 'request' should be preselected in this intermediary custom field.
The code of my relationship form:
[cred-relationship-form-container]
[cred-form-feedback field='feedback' name='feedback']
<div class="form-group">
<label>Benutzerprofile</label>
[cred-relationship-role role='parent' orderby='title' author='$current' class='cuteberry-relationshipformfield']
</div>
<div class="form-group">
<label>Reitanlagen</label>
[cred-relationship-role role='child']
</div>
<!-- I try to change this field -->
<div class="form-group">
<label>Organisatorrechte für das Anwesenheitsjournal</label>
[cred-relationship-field name='organisatorrechte-fur-das-anwesenheitsjournal']
</div>
<div class="form-group">
<label>Warum sollte ich Organisatorenrechte für das Anwesenheitsjournal haben?</label>
[cred-relationship-field name='warum-sollte-ich-organisatorenrechte-fur-das-anwesenheitsjournal-haben']
</div>
[cred-form-cancel field='cancel' name='cancel']
[cred-form-submit field='submit' name='submit']
[/cred-relationship-form-container]
This is the php which is in the documentation:
<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
/**
* Reset parent post ID on post edit form
*/
function ts_override_parent( $form_data ){
$form_id = '5888';
if ( $form_data['id'] == $form_id ){
// reset parent
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
$_POST['@selbstportrat-element_parent'] = '4702';
}
}
add_action( 'cred_before_save_data', 'ts_override_parent' );
Is there any documentation that you are following?
https://toolset.com/forums/topic/one-to-many-relationship-edit-post-form/page/2/#post-1564431
Nigel helped me to do something similar with a post form, where I changed the parents. I tried very hard to figure out, how I can do the same with the relationship form, but I does not work somehow
Is there a similar example that we can see?
Comepare answer above
What is the link to your site?
hidden link