I am trying to:
use this piece of code in the Toolset settings ...
<?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 = '4787';
if ( $form_data['id'] == $form_id ){
error_log('object: ' . print_r($_POST, true));
// reset parent
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
$_POST['@selbstportrat-element-portrat-user_parent'] = '4702';
}
}
add_filter( 'cred_before_save_data', 'ts_override_parent' );
to change the following CRED from before submission:
[credform]
[cred_field field='form_messages' class='alert alert-warning']
<div class="form-group">
<label>Qualifikation Reitlehrer</label>
[cred_field field='qualifikation-reitlehrer' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Mindestniveau Reitschüler Dressur</label>
[cred_field field='mindestniveau-reitschuler-dressur' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Mindestniveau Reitschüler Springen</label>
[cred_field field='mindestniveau-reitschuler-springen' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Buchungssystem -- Cuteberry | ### Porträt User</label>
[cred_field field='@buchungssystem-selbstportrat.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="4668"]']
</div>
<div class="form-group">
<label>Load Selbstporträt für Kunden oder für Dienstleister</label>
[cred_field field='@selbstportrat-element-portrat-user.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="4702"]']
</div>
[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]
I expected to see:
Both of the following things should change ...
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
$_POST['@selbstportrat-element-portrat-user_parent'] = '4702';
Instead, I got:
It's weired the following piece works
$_POST['@buchungssystem-selbstportrat_parent'] = '4668';
but this part, will not be changed
$_POST['@selbstportrat-element-portrat-user_parent'] = '4702';
Kind regards
Lara
Minesh
Supporter
Sprachen:
Englisch (English )
Zeitzone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
I see based on the code you shared that you are targetting the form with ID equal to 4787 - Can you please share details where I can see the form with ID 4787 on frontend, I mean where on what page you added that form?
Hi Minesh,
many thanks for your answer. You can find the form here: versteckter Link
It's the third form on this page. I deleted some of the fields (in my last post) to make the CRED form code more clearly.
Kind regards
Lara
Minesh
Supporter
Sprachen:
Englisch (English )
Zeitzone:
Asia/Kolkata (GMT+05:30)
Nigel contacted me that he will handle this issue with the original ticket you reported which he is handling.
So, please feel free to close this ticket. He will reply you with your following original ticket:
=> https://toolset.com/forums/topic/one-to-many-relationship-edit-post-form/page/2/