I am using this code to return the title of the post on a gravity form field.
add_filter('gform_field_value_page_name', 'page_name_filler');
function page_name_filler($value){
return get_the_title() ;
}
However, usually the title of the post is too long and it overfills the field. Hence I would only like to retain the first portion of the title before a comma "," if it exists on the title. Usually I will have multiple commas on my titles.
If a comma doesn't exist then the full title should be displayed.