Hi Tina
I got this working on a test site using the markup from the Bootstrap examples (hidden link) and my steps were as follows:
On my View which lists the parent posts I add the button that triggers the modal in the loop output section. I add an attribute to the button, data-id, which is the post id of the parent post (which is the current post in the loop in this view).
Here is the relevant part of the loop output:
<!-- wpv-loop-start -->
<wpv-loop>
<h3>My parent post: [wpv-post-link]</h3>
<button type="button" class="btn btn-primary btn-lg trigger-modal" data-toggle="modal" data-target="#myModal" data-id="[wpv-post-id]">
Create child for this post
</button>
</wpv-loop>
<!-- wpv-loop-end -->
Note that I added a class "trigger-modal" to the button which I will use later to target these buttons.
Now I add this view to a page, where I also add the markup for the modal with the CRED shortcode for the CRED form that creates a child post.
The page content looks like this:
<h2>Parent posts</h2>
[wpv-view name="list-parents-with-links-to-create-children"]
<div class="modal fade" tabindex="-1" role="dialog" id="myModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
[cred_form form='191' form_name='Alt Publish Child']
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Nothing special there, obviously the names of your view and form will be different.
So, when you visit this page the view that lists the parent posts together with the buttons to launch the modal is shown, and the markup for the CRED form in the modal is added below (although it is hidden until the modal is actually triggered).
We are missing the part that tells the CRED form which parent the child belongs to.
The parent posts are added to the form as a select dropdown, and we need the correct parent to be pre-selected when the modal is rendered.
So, go back to the View above which generates the button and add the following custom JS.
( function( $ ) {
$( document ).ready( function(){
$('button.trigger-modal').on( 'click', function( event ){
var postid = event.target.attributes['data-id'].value;
$('select[name*="_wpcf_belongs_parent-post_id"]').val(postid);
});
});
})( jQuery );
When you click a button to create a child post it should trigger the modal and pre-select the correct parent.