Spaces in multi-select values

This topic contains 5 replies, has 2 voices, and was last updated by  Kiran 4 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #523061

    Patrick
    Full Member
    Post count: 17

    Hello all,

    The API does not appear to support multi-select fields when values contain spaces. There’s nothing in the UX or front-end that prevents the use of spaces, so it appears to be a bug or oversight in the API implementation.

    For example, I have a multi-select field called ‘food_options’ that supports the following values: “Complimentary breakfast buffet,Complimentary snacks,Complimentary cold buffet,Complimentary hot buffet” among others.

    Any attempt to update this field fails with:

    {
        "code": "rest_invalid_param",
        "message": "Invalid parameter(s): food_options",
        "data": {
            "status": 400,
            "params": {
                "food_options": "food_options value \"Complimentary\" is not one of Complimentary breakfast buffet, Complimentary snacks, Complimentary cold buffet, Complimentary hot buffet, Complimentary soups, Complimentary finger food, Complimentary cooked-to-order meals, Complimentary full service restaurant, Food for sale."
            }
        }
    }

    I looked at the code and noticed that it does split strings on spaces regardless of other separators. However fixing the split does not help as there are deeper dependencies that do not support spaces. Please advise.

    Thanks,
    Patrick

    #523074

    Kiran
    Moderator
    Post count: 7069

    Hi Patrick,

    Let us know which option values you have used in that field in CPT > Settings > Custom Fields settings.

    Kiran

    #523092

    Patrick
    Full Member
    Post count: 17

    Here is a screenshot of the field settings. Note that I am experiencing this issue my all multi select fields and not only this particular one.

    #523139

    Kiran
    Moderator
    Post count: 7069

    Hi Patrick,

    I tested same option on my test site and it worked fine there.

    How you added option values to “food_options” field? Make sure you used “food_options” as an array.
    Example:

    &food_options[]=Complimentary cold buffet&food_options[]=Complimentary soups

    Let us know.

    Regards,
    Kiran

    #523153

    Patrick
    Full Member
    Post count: 17

    Thanks a ton! This seems to do the trick. Postman led me astray 🙂

    #523154

    Kiran
    Moderator
    Post count: 7069

    Thank you for letting us know.

    Kiran

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket