Cloneable Groups Validation And Form Reset Issue
Support › MB Frontend Submission › Cloneable Groups Validation And Form Reset Issue
- This topic has 4 replies, 2 voices, and was last updated 2 months, 2 weeks ago by
Peter.
-
AuthorPosts
-
August 6, 2025 at 7:19 PM #48654
Nicholas Cox
ParticipantHi
Im using cloneable groups, all working except when forcing an error during form validation where the row with the error is removed when the form is submitted. I have updated to the latest versions of the metabox extensions.
Shortcode when i edit the object url e.g. domain.com/form?rwmb_frontend_field_object_id=9
[mb_frontend_form id="dcp-payment-gateways" confirmation="Updated" ajax="true" object_type="model" edit="true"]
Screen recording of issue
https://screenrec.com/share/A7LzVdwoJZForm
global $wpdb; $meta_boxes[] = [ 'title' => 'Payment Gateways', 'models' => [self::$paymentGatewayClientsModel], 'storage_type' => 'custom_table', 'table' => $wpdb->prefix . self::$paymentGatewayClientsTable, 'id' => self::$metaboxFormId, //metabox id 'fields' => [ [ 'id' => 'user_id', //mysql table col 'type' => 'hidden', 'std' => get_current_user_id() ?? 0, ], [ 'type' => 'group', 'id' => 'data', 'name' => 'Payment Gateways', 'group_title' => 'Payment Gateways', 'clone' => false, 'collapsible' => false, 'default_state' => 'collapsed', 'save_state' => false, //do not save as it stores an entry into the db 'save_field' => true, 'fields' => [ [ 'type' => 'group', 'id' => 'stripe', 'name' => 'Stripe Accounts', 'group_title' => 'Stripe', 'clone' => true, 'max_clone' => 10, 'min_clone' => 0, 'collapsible' => false, 'default_state' => 'expanded', 'save_state' => false, 'clone_empty_start' => true, 'add_button' => '+ Add Stripe', 'fields' => [ [ 'id' => 'id', //mysql table col 'type' => 'hidden', 'std' => DripCreatePlatformHelper::generateRandomKeyByLength( 7 ), ], [ 'type' => 'text', 'name' => 'Domain', 'id' => 'domain', 'required' => false, 'columns' => 4, ], [ 'type' => 'text', 'name' => 'live Secret Key', 'id' => 'live_secret_key', //'limit' => 10, //default character length 'required' => false, 'columns' => 3, ], [ 'type' => 'text', 'name' => 'Webhook Secret', 'id' => 'live_webhook_secret', //'limit' => 10, 'required' => false, 'columns' => 3, ], [ 'type' => 'switch', 'name' => 'Enabled', 'id' => 'enabled', 'style' => 'rounded', 'on_label' => 'Yes', 'off_label' => 'No', 'std' => 0, 'columns' => 2, ], ], ], ], ], ], ];
August 6, 2025 at 10:11 PM #48661Peter
ModeratorHello Nick,
If you use the frontend validation, the form won't be saved if the condition is not met and the form will be reset to the previous saved data. I see it is an expected behavior. Please refer to this topic https://support.metabox.io/topic/back-end-validation-removes-unsaved-field-values
August 6, 2025 at 10:26 PM #48662Nicholas Cox
ParticipantIn older version's it used to keep the data in the form (using ajax) and for the client to finish off entering the rest of the required field data.
does this happen for all fields or just cloneable ones?
This would be bad for larger forms where it could take e.g. 10 minutes to fill out a form and a client missed one field value and validated with an error, then they will have to start over.
August 7, 2025 at 12:22 AM #48665Nicholas Cox
Participantah i can see why this is not working.
i needed to remove the
edit="true"
from the shorcode. I guess when passing a url param i dont need to have this enabled as im already editing the form. thanksAugust 7, 2025 at 11:13 PM #48673Peter
ModeratorHello,
Yes, correct. You need to remove the attribute
edit="true"
because the Ajax feature will be disabled.Allow users to edit the post after submitting. true or false (default). If true then ajax submission will be disabled.
It is noted in the documentation https://docs.metabox.io/extensions/mb-frontend-submission/#adding-the-submission-form
-
AuthorPosts
- You must be logged in to reply to this topic.