edit model and default values and submission issue
Support › MB Frontend Submission › edit model and default values and submission issue
- This topic has 6 replies, 2 voices, and was last updated 2 weeks, 6 days ago by
Nicholas Cox.
-
AuthorPosts
-
July 7, 2025 at 9:49 PM #48543
Nicholas Cox
ParticipantHi,
When editing a model object by url parameter using If I include a default value e.g. 'id' hidden field inside 'stripe' group. There is no default value in the default clone or when pressing clone (e.g. + Add Stripe) in the front end form. I checked developer toolbar https://ibb.co/4nSLNQc3 to confirm this. There is no value attribute added.
BUT if i remove edit="true" from the shortcut and just add a new entry without any url parameter for object_id (so just a new entry) then the default value appears correctly in each field input? so seems its just when editing a post and adding a new clone entry inside a group.
[mb_frontend_form id="dcp-payment-gateways" confirmation="Updated" ajax="true" object_type="model" edit="true"]
url e.g. http://localhost/dcplatform/payment-gateways/?rwmb_frontend_field_object_id=6
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, ], ], ], ], ], ], ];
also a side note, if i edit a model by
object_id
as stated above, the post saves successfully but the form is redirected from e.g. http://localhost/dcplatform/payment-gateways/?rwmb_frontend_field_object_id=6 to http://localhost/dcplatform/payment-gateways/?rwmb_frontend_field_object_id=0&rwmb-form-submitted=0301c03df73331511d525bc4ea445dcbSo the
rwmb_frontend_field_object_id=0
should stay as 6. This happens since the latest update for me for all extensions. But cant say 100% for sure if its the latest version causing this issue.thanks
Nick
July 8, 2025 at 9:48 PM #48548Peter
ModeratorHello Nick,
Thanks for reaching out.
I can reproduce the #1 issue. This happens when you don't add any value to the field group and submit the form. You can try to add at least a field value or remove the setting
clone_empty_start
to fix this issue.I cannot reproduce #2 issue because the object ID 0 is not available in the database. The column ID is incremental and starts from 1. Do you use any custom code to adjust the form?
July 14, 2025 at 8:50 PM #48561Nicholas Cox
Participanthi yes issue #1 but having the option to clone_empty_start makes it so if the customer does not enter anything then nothing is saved. So this surely should be an option? seems strange to show at least 1 group for all groups, this make the form longer to scroll and ruins the ux.
Yes for issue #2 i can not sometimes reproduce it too, it happens intermittently and no i do not have any custom code on this.
July 14, 2025 at 11:18 PM #48562Peter
ModeratorHello Nick,
I've escalated the #1 issue to the development team to fix this. For #2 issue, if you know how to reproduce the issue with clear steps, please let me know. I will investigate it and get back to you soon.
August 6, 2025 at 5:08 PM #48652Nicholas Cox
ParticipantHi Peter,
In regards to issue #2 the form details are earlier in this post.
So im using this shortcode
[mb_frontend_form id="dcp-payment-gateways" confirmation="Updated" ajax="true" object_type="model" edit="true"]
then in the browser i go to the page and enter the object_id in the url paramater
http://localhost/dcplatform/payment-gateways/?rwmb_frontend_field_object_id=5
You can see my database with one entry
video recording of the issue
https://screenrec.com/share/vVLTZw2NXlWhat else can i provide you with?
thanks
Nick
August 6, 2025 at 9:10 PM #48658Peter
ModeratorHello Nick,
Thanks for the details. I can reproduce the issue on the demo site. It has been escalated to the development team and we will fix it as soon as possible.
August 6, 2025 at 10:28 PM #48663Nicholas Cox
Participantok thanks
-
AuthorPosts
- You must be logged in to reply to this topic.