I don't think I understand you
What do I have to change?
You must change the value attribute. You currently have this:
value='Campaña Bonos Inicial'
You must use the parent post ID, not the parent post title. If the ID of the Campaña Bonos Inicial parent post is 12345, for example, the code must be changed to this:
You cannot use the parent post title in the value attribute, you must use the parent post ID.
Well you shouldn't be able to use the select field on the front-end because you have set readonly="true". That makes the field unchangeable. However, the parent post should be visible in the select field when you set the value. I'd like to see what's happening. Can you provide a URL where I can see this on the site?
It seems that the readonly attribute is causing the problem here. If I remove it, the field works as expected:
[cred_field field='@campana-bonos-bono.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' value='5168']
I will keep investigating this to see if there is a problem in Forms or if I've misunderstood how the readonly attribute works in post relationship fields. For now, you could just hide the entire Campaña field on the front-end using CSS, since you want to set the value programmatically and not allow the User to edit it:
<div class="form-group" style="display:none !important;">
<label>[cred_i18n name='@campana-bonos-bono.parent-label']Campaña[/cred_i18n]</label>
[cred_field field='@campana-bonos-bono.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' value='5168']
</div>
Or you could set the relationship programmatically by removing the field entirely and using the toolset_connect_posts API in a cred_save_data callback:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
It would be arguably more secure this way.
Thank you Cristhian
Is it possible that the date field is the current date on which the coupon is created?
Yes, you can remove the date field from the Form and use custom code to set the value programmatically. The code is similar to an example I shared in another ticket:
add_action( 'cred_save_data', 'tssupp_auto_set_date_field_for_bono', 10, 2 );
function tssupp_auto_set_date_field_for_bono( $post_id, $form_data ) {
$form_id = 12345; // your form ID
$field_slug = 'your-date-field-slug';
if ( $form_data['id'] == $form_id ) {
update_post_meta( $post_id, 'wpcf-' . $field_slug, date('U') );
}
}
Thanks Cristhian,
This work fine. But how i cant modified custom type (ticket in other conversation) i cant continue with process.
Okay I'm still investigating that issue and will give you an update shortly.
Updated, let me know when you're ready to move forward here.