Select Field With Multiple Not Saving

Support MB Frontend Submission Select Field With Multiple Not Saving

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #49073
    collinsonfamily@gmail.com[email protected]
    Participant

    I have a select field with multiple options that doesn't save. I don't get any errors but the values are not saved in the post. This happens with a select or select advanced field. I have enabled the save field value option but this makes no difference. This is the code that my field has generated:

    [
    'name' => __( 'Location', 'your-text-domain' ),
    'id' => $prefix . 'location',
    'type' => 'select_advanced',
    'options' => [
    'Hall' => __( 'Hall', 'your-text-domain' ),
    'Sports Hall' => __( 'Sports Hall', 'your-text-domain' ),
    'Chapel' => __( 'Chapel', 'your-text-domain' ),
    'Dining Room' => __( 'Dining Room', 'your-text-domain' ),
    'Drama Studio' => __( 'Drama Studio', 'your-text-domain' ),
    'Junior School' => __( 'Junior School', 'your-text-domain' ),
    'Other' => __( 'Other', 'your-text-domain' ),
    ],
    'multiple' => true,
    'select_all_none' => true,
    'required' => true,
    ],

    #49074
    PeterPeter
    Moderator

    Hello,

    I try to reproduce the issue but don't see that. The field value is saved to the database as well. Does this happen with other field types? Do you see any errors in the Console tab of the browser inspect tool or in the WP debug log?

    Also, can you please try to increase the PHP setting max_input_vars as I mentioned in the previous topic
    https://support.metabox.io/topic/cannot-save-new-fields-or-change-location-to-user/

    #49075
    collinsonfamily@gmail.com[email protected]
    Participant

    I've figured out what's breaking it. I have a filter that converts the array into a comma separated string:

    add_filter( 'rwmb_location_value', function( $value, $field ) {
    if ( is_array( $value ) ) {
    return implode( ', ', $value );
    }
    return $value;
    }, 10, 2 );

    If I remove this filter, it works again. I just now need to figure out how to get the same output without breaking it.

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