Hi Bob
The Gym site doesn't include a way to add opening hours from the front end, for a reason, namely that the workflow is somewhat awkward, and if you want a reasonable workflow it requires a little bit of custom code using the Forms API (the Reference sites do not include features that depend on custom code).
It is not possible to include repeatable groups of fields within a form to publish or edit posts that the fields belong to. As currently configured Forms can only publish (or edit) a single post at a time, and repeatable groups of fields are implemented using post relationships (each group of fields belong to a post, which is a child post of the post the fields "belong" to).
Hence the workflow for adding repeatable groups of fields from the front end is very much like that for adding child posts to an existing parent, and requires separate forms to publish the parent and to publish the child repeatable groups of fields.
I have set up a demonstration using the Gym reference site of what I consider the most frictionless workflow for adding repeatable groups of fields (in this case, adding opening hours to a gym).
In the screenshot you can see how a gym post appears on the front end, using the updated content template.
There is an existing link to edit the gym (visible to the author of the gym post), and I have added a link to add Opening Hours below where the existing opening hours are shown.
If you click that link it takes you to a page with a form to add opening hours (one opening hour post, e.g. for Thursday). When you complete and submit that form then it returns to the display of the gym post as per the screenshot, from which you can then click the link to add more Opening Hours as required.
To see how this was implemented, use this link to log in to the site: https://shiny-tabla.sandbox.otgs.work/?auto=rQo1wVIyzyJJ5kzlEBOzn1vLskIGpwgN
At Toolset > Forms you'll note a new form, Add Opening Hours.
If you edit it, as well as the fields themselves, note the settings, to publish a post of the post type pertaining to the RFG Opening Hours. And note the setting to redirect to the homepage after the form is submitted. We will override this with code, to redirect back to the parent gym, but the code will only be triggered if the form is trying to redirect somewhere.
Lastly, note that the form includes a title field which is required, and so I have provided a default value (the title of the parent Gym), although I would hide the field using CSS as the user does not need to see it. Similarly, hide the select field for the parent Gym, which will be populated with the ID of the gym that links to the form, but which users do not need to see.
Now, edit the Content Template for displaying Gym posts, and note how I added a Fields and Text block below the View that displays opening hours, to generate the link to the form to add Opening Hour posts. You can see the resulting cred_child_link_form shortcode (which I generated by clicking the Forms icon in the Fields and Text block).
Lastly, if you go to Toolset > Settings > Custom Code you will see a code snippet that I added which uses the cred_success_redirect hook to override where the form redirects to upon submission (using the ID of the parent gym available from the $_REQUEST or $_POST object that contains details of the form field entries).
You could use similar techniques, editing the output of the View that displays the Opening Hour posts to add edit and delete links for each row of the Opening Hours table, bearing in mind that you would handle these in the same way as linking to forms to edit or delete child posts.
By all means test the form submission to see the workflow, but please don't change the settings, I have another user with a similar question who will be looking at the same site.
For reference, here is the code used for the redirect:
/**
* Redirect RFG form back to its parent post upon submission
*/
add_filter('cred_success_redirect', 'ts_redirect_rfg_form',10,3);
function ts_redirect_rfg_form($url, $post_id, $form_data)
{
if ( $form_data['id'] == 14458 && isset( $_REQUEST['@opening-hours_parent'] ) )
{
$url = get_permalink( $_REQUEST['@opening-hours_parent'] );
}
return $url;
}