Forum Replies Created
-
AuthorPosts
-
Nicholas Cox
Participantwhen setting the max_clone to 2 or more this is not an issue with auto populating forms, just when its set to 1.
Nicholas Cox
ParticipantHi, i have checked this over and recreated a new one and the problem has gone away but the issue still persisted with the population of the form using the url param
?rwmb_frontend_field_object_id=1I started to remove the settings in the form back and noticed the following setting for max_clone is causing the issue to populate groups from serialized arrays.
'max_clone' => 1if i remove this then i can auto populate the form correctly and also successfully update the entry using the shortcode.
So i assumed the form was not auto populating as my form only contains a group field. All other fields populate correctly.
Any ideas why the max_clone of 1 is not working?
Nicholas Cox
Participantyes i add more entries and then try to edit them and i receive the same warning about capability.
Ok ill setup a test site, but before here is the code im using incase im missing something.
public function paymentGatewayFormFields( $meta_boxes ) { global $wpdb; $meta_boxes[] = [ 'title' => 'Payment Gateways', 'models' => [self::$paymentGatewayClientsModel], 'storage_type' => 'custom_table', 'table' => $wpdb->prefix . self::$paymentGatewayClientsTable, 'id' => self::$metaboxFormId, 'fields' => [ [ 'id' => 'user_id', '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, 'save_field' => true, 'fields' => [ [ 'type' => 'group', 'id' => 'stripe', 'name' => 'Stripe Accounts', 'group_title' => 'Stripe', 'clone' => true, 'max_clone' => 1, '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', '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' => 1, 'columns' => 2, ], ], ], ], ], ], ]; return $meta_boxes; }Nicholas Cox
ParticipantHi Peter,
Sorry for the delay, was away. I have done a screen recording showing im signed in as an administrator who posted the entry and with one result in the model database table, the shortcode and the test page.
thanks
Nick
Nicholas Cox
ParticipantHi Peter,
Ok that makes sense now, I have set the
object_typetomodeland tested an all working ok now. Many thanksNicholas Cox
ParticipantHi,
I will get a screen recording, but before i do I thought I read somewhere that I can use front end forms with custom models and custom tables now (but cannot find the information), as i posted this a few years ago https://support.metabox.io/topic/front-end-submission-and-custom-models/ which said that this was not supported. Can you confirm if custom models works with front end submission now? as i believe this is the reason why its not working.
thanks
Nicholas Cox
ParticipantSo I have over 800 wordpress posts and when I insert the first row into a model table the ID is set to e.g. 806. Its weird behaviour not to be how metabox inserts new row values into custom model tables
Nicholas Cox
ParticipantHi. Yes try adding a few default wordpress posts first and then try adding a row to the custom models database table. As I'm not sure if your test environment matches to replicate my issue? If not then no worries.
What your describing is normal behaviour in regards to deleting the first databass table entry and adding a new entry which assigns an id of 2 etc... mysql tables behave like this with auto increment columns.
My theory is that metabox is using some logic with posts which is causing the issue. As I have tested manually by inserting a new value and it works as intended with the first row having an id of 1.
Any ideas? Thanks
Nicholas Cox
Participantyes i was just checking as the form keeping loading for a long time and never times out or displays and error message if the
post_max_sizeetc is exceeded. How do we handle these scenarios using front end forms? is there a way to auto fail validation? thanksJanuary 21, 2025 at 9:23 PM in reply to: ℹ️empy first array value for cloneable group when using rwmb_frontend_validate #47488Nicholas Cox
ParticipantHi yes but when validating using
rwmb_frontend_validateyou have to do additional checks to see if the first value is empty or not also if the clone max is set to 1 then the array is no longer a nested array which means another check to see if its a single array or nested array.I was just checking with you as there is inconsistencies in the array returned when different settings are enabled and disabled, there is no guide on metabox validation array checks in the docs and what to look out for.
thanks
Nick
Nicholas Cox
ParticipantYes it seems it takes the next available wordpress post ID and not the next available ID of the custom model database table.
Nicholas Cox
Participantignore the first code as this was just an example and not the correct code, but the issue still persists with the form code being correct to that of the table structure, i cannot edit my first post.
Nicholas Cox
ParticipantHi Peter,
I did some investigation and turns out this CSS call I had in my custom CSS file (not metabox related) was causing the issue. So once I removed this all is working as it should.
.rwmb-form .rwmb-clone.rwmb-clone-template { display: inherit; }December 29, 2024 at 5:41 PM in reply to: ✅Field group not loading collapsed when editing a front end post #47261Nicholas Cox
ParticipantHi,
I did some investigation and turns out i had some JS issues which was affecting the form and not related to metabox scripts. So thanks anyway, i find it hard sometimes to debug JS errors.
To confirm the save_state works as it should.
Nicholas Cox
ParticipantHi
Its a custom field, its basically a file upload which converts it to a base64 string. Then the idea being when they submit the form i process the base64 image and then save a image path when validating.
I was asking about the POST size as i am not uploading the files before the form is submitted the PHP post size is increased. I just wondered if there is a limit to what can be sent with metabox? or is this dependent upon the server setup?
-
AuthorPosts