edit model and default values and submission issue

Support MB Frontend Submission edit model and default values and submission issue

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #48543
    Nicholas CoxNicholas Cox
    Participant

    Hi,

    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=0301c03df73331511d525bc4ea445dcb

    So 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

    #48548
    PeterPeter
    Moderator

    Hello 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?

    #48561
    Nicholas CoxNicholas Cox
    Participant

    hi 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.

    #48562
    PeterPeter
    Moderator

    Hello 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.

    #48652
    Nicholas CoxNicholas Cox
    Participant

    Hi 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
    mysql

    video recording of the issue
    https://screenrec.com/share/vVLTZw2NXl

    What else can i provide you with?

    thanks

    Nick

    #48658
    PeterPeter
    Moderator

    Hello 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.

    #48663
    Nicholas CoxNicholas Cox
    Participant

    ok thanks

    #48885
    Nicholas CoxNicholas Cox
    Participant

    Hi, any update on this?

    #48894
    PeterPeter
    Moderator

    Hello Nick,

    This issue has been fixed in the new version Meta Box AIO 3.0.1. Can you please recheck this on your site?

    #48902
    Nicholas CoxNicholas Cox
    Participant

    Hi, I am not using Metabox AIO? im been using this setup for the last few years. So is the metabox main plugin 'wpackagist-plugin/meta-box' not have the updates anymore?

    "require": {
        "wpackagist-plugin/meta-box": "dev-trunk",
        "wpackagist-plugin/meta-box-text-limiter": "dev-trunk",
        "meta-box/mb-admin-columns": "dev-master",
        "meta-box/mb-blocks": "dev-master",
        "meta-box/mb-custom-table": "dev-master",
        "meta-box/mb-frontend-submission": "dev-master",
        "meta-box/mb-settings-page": "dev-master",
        "meta-box/mb-user-meta": "dev-master",
        "meta-box/mb-user-profile": "dev-master",
        "meta-box/meta-box-conditional-logic": "dev-master",
        "meta-box/meta-box-group": "dev-master",
        "meta-box/meta-box-tabs": "dev-master",
        "meta-box/meta-box-columns": "dev-master",
     }

    thanks

    Nick

    #48912
    PeterPeter
    Moderator

    Hello,

    The fix for this issue is included in the plugin MB Frontend Submission, version 4.5.4. Please ensure that you have this version on your site and recheck the issue.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.