I am receiving this error on my CRED form in the frontend:
There is a problem with @person-to-shiur-location.parent field. Please check CRED form.
I checked the backend over here:
hidden link
But I can't seem to find anything wrong with it.
Thanks
Hi,
Thank you for contacting us and I'd be happy to assist.
The relationship "Shiur Locations -> People" (slug: person-to-shiur-location) is a many-to-many relationship, which is why this field is not working.
The relationship field can be used in the post form, only if it is possible to select only one parent post. For example, if this relationship was one-to-many, then yes, you'd be able to select one parent "Shiur Locations", through this form to add a "People" post.
For this case, you'll need to use a separate relationship form, where the visitor can select a 'Shiur Location' and 'People' post to connect in a relationship.
( ref: https://toolset.com/course-lesson/front-end-relationship-forms-for-connecting-posts/ )
regards,
Waqar
Thanks for explaining Waqar,
So I'm working on the relationship form, and I came across this thread that is similar to mine: https://toolset.com/forums/topic/linking-post-form-and-relationship-form/
If you take a look at the form again, you'll see the relationship form is directly below the submit button of the post form. Is there a way to make the relationship form hidden until the user clicks on the "Submit" button, and immediately thereafter it'll display? This way it will look more like one long form. (I will also then change the word from "Submit" to "Continue", so that it's more streamlined).
Also, is there any way to change the placeholder text "Search for a post"?
Thanks,
Sim
Thanks for writing back.
If I understand correctly the website has the page "Add New Shiur Location", which shows the 3 forms in 3 tabs, and the "Add Contact" is one of those forms.
As it is possible to connect more than one "Shiur Locations" to the created "People" post, it would be better to take the visitor to the newly created single "People" post page, when the "Add Contact" form is submitted successfully.
On the single "People" post page, you can show the "Connect a Person to a Location" relationship form, where the people post field will automatically be selected with the current people post and the user will only have to select the "Shiur Locations" post to connect. And the user can use the same form repeatedly, to connect more locations to the current people's posts, as needed.
This single people post page will also act as the management page to see which "Shiur Locations" posts are already connected using a post view with the relationship filter. And inside the view, you can also include the link to disconnect a "Shiur Locations" post from the current people post.
As for the "Search for a post" placeholder in the relationship form, there is no option to change that, so you can use the "gettext" filter to customize/translate it.
( ref: https://developer.wordpress.org/reference/hooks/gettext/)
For example:
add_filter( 'gettext', 'custom_translate_text_func', 20, 3 );
function custom_translate_text_func( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Search for a post' :
$translated_text = __( 'New text for Search for a post', 'wpv-views' );
break;
}
return $translated_text;
}
Note: Please replace "New text for Search for a post" with the new text that you'd like to see.
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
Hi Waqar,
So there won't be any "Single" post page for people, it is simply used for information in my view, and 90% of the info in the form is not displayed publicly. You were correct that I was referring to the add-contact form inside the 3rd tab, and I was hoping to have the form + relationship form look like one long form, because to any random user, they won't understand why it isn't one long form to begin with.
If hiding it until the user hits Submit won't work, are there any other options that can make it seem as one long form?
Thanks,
Sim
The added challenge here is that when the "Add Contact" form is submitted the page refreshes and the first tab "Add a Shiur Location" is active.
( the message "Contact Person Saved" for the form success is not visible unless you switch to the "Add a Contact" tab manually )
If it was a page without the tabs, conditional code could be used to detect the parameters available in the URL, to conditionally show/hide the "Add Contact" form and "Connect a Person to a Location" form.
I'll request you to review the requirement that you're planning to achieve because I feel even if you're able to implement it, it would be very unintuitive and confusing for the users.
You have a page "Add New Shiur Location", but, there are 3 tabs that can be used to add 3 different types of post items (Add a Shiur Location, Add a Shiur, and Add a Contact ).
If the relationship "Shiur Locations -> People" was of type "one-to-many" the user would be able to select the one possible "Shiur Locations" post to join, right from the "Add Contact" form and that would be the end of that process. However, the relationship "Shiur Locations -> People" is of type "many-to-many" and a People post can be connected to multiple Shiur Locations posts. This makes connecting Shiur Locations and Peoples posts, a process of its own and not a sub-process of creating a new people post.
The first thing that you'll need to review is that do you really need the "Shiur Locations -> People" relationship to be "many-to-many"? If the answer to that is "Yes", then I can think of two possible approaches to move further:
1. As suggested in my last reply, you can bring the single "People" post page in the play for the "Shiur Locations -> People" relationship management.
OR
2. You can add a 4th tab on the "Add New Shiur Location" page and name it something like "Connect Contact" or "Contact Management" and show the relationship form "Connect a Person to a Location" in that tab.
I hope this makes sense.
So I changed the header to be more generic, thank you for pointing that out. (Now it just says "add to the directory")
The answer is Yes, that I need it to be many-to-many, and I guess option #2 is best. Is there a way I can hide this new "Contact Management" tab until the user hits "Submit" on the "Add a Contact" form? This way, if a user comes to the page they won't be confused about which tab to choose, it will only show up after Submitting.
To achieve this, you can follow these steps:
1. When the "Add Contact" form is submitted successfully and the page is refreshed, the URL contains this parameter: _success=3607_1_1
You can register a custom shortcode that looks for the availability of this URL parameter value and shows the 4th tab, only when it is set:
add_shortcode('include_CSS_to_hide_tab', 'include_CSS_to_hide_tab_func');
function include_CSS_to_hide_tab_func() {
ob_start();
if( (empty($_GET['_success'])) || (!isset($_GET['_success'])) || ($_GET['_success'] != '3607_1_1') ) {
echo '<style> .elementor-section-wrap .elementor-tabs .elementor-tab-title[data-tab="4"] {display: none;} </style>';
}
if( $_GET['_success'] == '3607_1_1' ) {
echo '<style> .elementor-section-wrap .elementor-tabs .elementor-tab-title[data-tab="4"] {display: table-cell;} </style>';
}
return ob_get_clean();
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
2. Next, you can include a "Shortcode" module in the Elementor editor for the page "Add New Shiur Location" and add this new shortcode in it:
[include_CSS_to_hide_tab]
The result will be that, when the page will load, the 4th tab will be hidden. but, when it will reload after successful submission of the "Add Contact" form, the tab will become visible.
Worked like a charm. My issue is resolved now. Thank you Waqar!