Forum Replies Created
-
AuthorPosts
-
Gerard Halligan
ParticipantThanks Peter but the form still doesn't show?
I updated the bootstrap file to the below
$renderer = new Renderer( $meta_box_renderer );
new Shortcode( $renderer );if ( is_admin() ) {
$location = new Location\Settings;
new Editor( $location );
new ConditionalLogic;
new AdminColumns;
new Category;
new Import;
new Export;
} else {new ActionLoader( $renderer );
new TemplateLoader( 'singular' );
new TemplateLoader( 'archive' );
new TemplateLoader( 'code' );new ContentLoader( $renderer, 'singular' );
new ContentLoader( $renderer, 'archive' );
new ContentLoader( $renderer, 'code' );
}This is my ajax code. you can ignore the references to transient. I just modified to see if the shortcode was working. The issue is that do_shortcode("[mb_frontend_form id='amelia-custom-field-group']"); returns ''?
add_action('wp_ajax_insert_inss_mb_attendee_form', 'insert_inss_mb_attendee_form'); add_action('wp_ajax_nopriv_insert_inss_mb_attendee_form', 'insert_inss_mb_attendee_form'); function insert_inss_mb_attendee_form() { $output = do_shortcode("[mb_frontend_form id='amelia-custom-field-group']"); //$output = get_transient('amelia_custom_field_group_output'); if ($output === false) { error_log(__METHOD__ . " Transient not found or expired"); echo '<p>No output from shortcode.</p>'; } elseif ($output === '') { error_log(__METHOD__ . " No output from shortcode"); } else { echo $output; } wp_die(); // This is required to terminate immediately and return a proper response }js ajax call
function callInsertMBInssOrderForm(bookingCostDiv) { // Check if the div with class 'rwmb-meta-box inss_custom_fields' exists if (bookingCostDiv.querySelector('.inss_custom_fields')) { return; // Exit the function if the div exists } fetch(<code>${ajaxurl}?action=insert_inss_mb_attendee_form</code>, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({}) }) .then(response => response.text()) .then(mbOrderForm => { // Append the response data (shortcode HTML) to the start of the div with class am-custom-fields const customFieldsDiv = bookingCostDiv.querySelector('.am-custom-fields'); if (customFieldsDiv) { if (customFieldsDiv.querySelector('.inss_custom_fields')) { return; } customFieldsDiv.insertAdjacentHTML('afterbegin', mbOrderForm); handleMetaboxGroupCloning(customFieldsDiv, numberOfPeople) } else { console.error('Error: .am-custom-fields element not found'); } }) .catch(error => { console.error('Error:', error); }); }Gerard Halligan
ParticipantHi Peter,
In my case it is a form I want to insert by ajax through a MutationObserver, when a certain div is created.
Whenever I try to call do_shortcode in the ajax call, it returns nothing. I tried to work around it by calling the shortcode in wp_loaded and saving the output to a transient. I thought this worked, as I was able to output the form when i got the transient value through the ajax call and output it in the right place on my page, but the form mustn't be fully initialised and parts of it don't work like the date picker, conditional logic.Could the fix you are working on for views also be a fix for forms?
Thanks,
GerGerard Halligan
ParticipantI have the same issue. Were you able to fix it?
Thanks,
GerGerard Halligan
ParticipantHi Peter,
I was able to use the action rwmb_frontend_after_display_confirmation, to recreate the form for the current post.
But, if I click update again, I get this errorService Unavailable
The server is temporarily unable to service your request. This normally means the PHP worker exited unexpectedly. Please try again later.It looks like ajax fails to run on the new form. Is this the unexpected errors you where referring to?
If I set ajax to false on this new form, then the form saves and the page reloads and I the form can be saved by ajax this time. Is there anything you can think of to allow the newly created form to use ajax as well?add_action( "rwmb_frontend_after_display_confirmation", "reload_edit_form_on_submit", 10, 1 ); function reload_edit_form_on_submit($config) { if (isset($config["post_id"]) && $config["post_id"]) { // Modify the 'edit' and 'post_id' configurations for form to be reshown //$config['edit'] = 'true'; $post_id = $config["post_id"]; //$config['ajax'] = false; // Create new form with updated configurations $form = \MBFS\FormFactory::make($config); // Start buffering ob_start(); // Render the newly created form $form->render(); // Flush buffer and get all content $form_html = ob_get_clean(); // Save the changes to the form_html variable $form_html = $document->saveHTML(); echo $form_html; } }Gerard Halligan
ParticipantCan I reload the form for the current post using ajax after the rwmb_frontend_after_submit_confirmation?
Gerard Halligan
ParticipantThanks Peter. Yeah, I'm aware of the Edit option, but unfortunately it won't work in my scenario. I am creating a task manager, and I have the task shown in a query loop. The user can edit the task directly from the shown task posts using the MB submission form. This works, except once they save the post, the form dispears for that task, and can't be edited again unless the page is reloaded. I can't use the edit option, as it also reloads the page and adds the post id to the url.
From your comment, it sounds like there is no hook that I can use to modify this behaviour, is this the case?Thanks,
GerSeptember 30, 2023 at 3:08 AM in reply to: Creating Signature Field for MB Frontend Submission #43385Gerard Halligan
ParticipantHi Long,
Any update on this? I also use GF for any form that requires a signature, but would love to be able to use MB for them. A MB signature field would be very useful.Thanks,
GerGerard Halligan
ParticipantHi Peter,
Thanks for looking at this.
I did try that initially, and I was able to style the form correctly, but the issue with using groups is that it changes how the data is saved in the db. The CPT already has data in it, so I need a layout that only wraps the fields in a DIV. but they are still saved as individual meta keys and values.
But, I had a look at your links and that reminded me of the before and after options. I can use them to add in a div, around the fields I want to group, so I guess it's not needed. It would look nice though, if you could see the grouping in the designer 😉
Thanks for your help
GerSeptember 23, 2023 at 6:29 PM in reply to: ✅Button Field: Open "Add New" post in modal window #43340Gerard Halligan
ParticipantIs there any update on this, this would be very useful to have.
July 1, 2022 at 1:26 PM in reply to: ✅Geolocation failed to load - how to identify the issue? #36760Gerard Halligan
ParticipantThat's great, thanks 👍
June 27, 2022 at 8:24 PM in reply to: ✅Geolocation failed to load - how to identify the issue? #36683Gerard Halligan
ParticipantIt's definitely an issue with the latest update AIO 1.162. I rolled back to 1.15.8 and it's working again.
Gerard Halligan
ParticipantI forgot to say, that I made some slight CSS edits to always show the action buttons. I also hide the edit button, since I only want someone to delete the image and add another. The buttons didn't work before this either, and I only started take the CSS changes to see if there was something overlaying it and blocking touches. If I keep tapping away around it, it does eventually work. But it never worked clicking on it.
Thanks
Gerard Halligan
ParticipantHi Long Nguyen,
Thanks for getting back to me.
Here a link to a video of what I mean.
https://www.dropbox.com/s/j6wk4n44amtrtdz/screen_recording_20220623-071222_edge.mp4?dl=0
I'll try what you recommended as well and let you know.
If you can't view the video, please let me know.
Thanks,
GerJune 23, 2022 at 2:37 AM in reply to: ✅Geolocation failed to load - how to identify the issue? #36633Gerard Halligan
ParticipantHi, I'm also experiencing this issue. Is there any update?
Thanks,
GerGerard Halligan
ParticipantHi Nguyen,
I was able to work around this. I used the listener I had added for the clone button click event to search for the duplicate div and remove it. I had to add a delay, so the cloned elements get created, so there is a slight flicker of the images before they are removed.
As an added feature for clone groups, could you look into a way to exclude elements with a specific class for example?
Thanks,
Ger -
AuthorPosts