edit model and default values and submission issue

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

Viewing 1 post (of 1 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

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.