With nested view... I wourld filter by custom fields of menus? I think... NOT. Or Yes?
No, unfortunately that would not be possible. You could only filter by fields of Restaurants in this case, since the parent View is a view of Restaurants.
Then... the only way to filter menus by distance is that menus have their own address?
Yes, that is correct. If you want to filter menus by distance AND by other custom fields in the menu post type, you must include an address in every Menu post.
Is there any way to save adress of restaurant in a custom field of menu when I create or edit a menu with a form?
You could create an address field on the Menu post type, and add the address manually in the Form for each Menu post. Or, you could use custom code to automatically copy the address from the parent post into an address field in the menu post. We have an API available cred_submit_complete that can be used to automate a custom field value. We have an API available toolset_get_related_post that can be used to get information from a parent post. Here's an example using those APIs together:
// https://toolset.com/forums/topic/distance-filter-doesntt-work/
// automatically copy parent address field into child address field
add_action('cred_submit_complete', 'tssupp_copy_parent_address',10,2);
function tssupp_copy_parent_address($post_id, $form_data)
{
$forms = array( 123, 456 );
$relationship_slug = 'book-chapter';
$parent_address_slug = 'parent-address';
$child_address_slug = 'child-address';
// you should not edit below this line
if ( in_array( $form_data['id'], $forms ) )
{
$parent_id = toolset_get_related_post( $post_id, $relationship_slug, 'parent' );
if ( $parent_id )
{
$parent_address = get_post_meta( $parent_id, 'wpcf-' . $parent_address_slug, true);
if ( $parent_address )
{
update_post_meta( $post_id, 'wpcf-' . $child_address_slug);
}
}
}
}
You would replace 123, 456 with a comma-separated list of the numeric IDs of any Forms that create child posts. You can find those IDs in Toolset > Post Forms. You would replace book-chapter with the slug of the relationship between restaurants and menus. You can find that slug in Toolset > Relationships. You would replace parent-address with the slug of the address field in the Restaurants post type. You can find that slug in Toolset > Custom Fields > Post fields tab. You would replace child-address with the slug of the address field in the Menus post type.
You should add this code in a child theme's functions.php file, or add it to a new custom code snippet in Toolset > Settings > Custom Code. Set the snippet to "run everywhere" and be sure to Activate the snippet. When you submit the Form to create a new child post, the address field from the parent post will be automatically copied into the Menu post.
Documentation for these APIs and the WP APIs used in the code is available here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
https://developer.wordpress.org/reference/functions/get_post_meta/
https://developer.wordpress.org/reference/functions/update_post_meta/