Hi Rob, the user filling the form, be it when creating the post or later when editing the post, is always logged in. So that doesn’t work. What I thought should work is using the url parameter „entry“ which doesn’t exist if the form is used to create a post. When editing, it contains the id of the formidable forms entry, eg „entry=54“.I tried to use this parameter being pulled as default value into a hidden field using get param. But when using it in a visible text field for testing purposes, it shows a blank although the parameter exists. I find this strange!
Separately, I found a hook function to make certain fields non-editable when in edit mode. But that doesn’t help either for the credit card data which isn’t stored on my site. Isn’t there any hook to HIDE fields when in editing mode? This might be the easiest solution. Otherwise, perhaps there is an alternative approach for my url parameter idea outlined above? Or something completely different? Thank you! Best regards, Ralph
Hi Rob, a quick update: I made it work! I added the following javascript (jQuery) in the HTML editor ("after the fields" section). In case the URL parameter "entry" exists, it hides the fields, in the example field id 255. It also changes the header, but thats just the cherry on top of it. An interesting detail with regards to the URl parameters: when in editing mode, it seems that the shortcode [get param=XYZ] in the default field value settings doesn't work. This only works when using the form in "entry mode". Best regards, Ralph
<script type="text/javascript">
jQuery(document).ready(function($){
// Function to get URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// Check if "entry" parameter exists
if (getUrlParameter('entry')) {
// Hide fields if "entry" parameter exists
$("#frm_field_255_container").css('display','none');
$('h1').text('EDIT Listing');
document.title = 'Anzeige bearbeiten';
$('meta[property="og:title"]').attr('content', 'EDIT Listing');
}
});
</script>
Please login or Register to submit your answer