BuddyDev

Search

Custom values multiple selection box

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26693

    Hi, I’m copying a code snippet to import the data sent from a form to the buddypress profile. This works well. Except the field_87 that the value is a string (there are several locations) and when I choose option * multiple selection box * for example this is show separated by commas and when I edit it, it is empty.

    Any idea how I can add this value separately in an xprofile?
    for example if I choose the option in a text box it appears: “France, Paris, Buenos Aires, Argentina” when i wrote two locations. i hope you can me understand me.

    ` $usermeta = array(

    //name
    ‘field_1’ => $form->getValueText(‘quform_7_10’),
    ‘field_59’ => ‘Home’,
    //multiple locations
    ‘field_87’ => $form->getValueText(‘quform_7_23’),

    );

    $usermeta[‘profile_field_ids’] = ‘1,43,59’;`

    Thanks very much!

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #26705

    Hi Jennifer,
    The multi option values are stored as serialized value. Can you please check from your import that the field id has data in serialised form? Also, to be editable(selected on edit page, they will be case sensitive).

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26720

    Hi Brajesh. thanks for your answer!
    No, it isnt.do you mean add something like that?

    $(document).ready(function(){
      $("button").click(function(){
        $("div").text($("form").serialize());
      });
    }); 

    I m thinking that the answer is generate like a repeater fields in xprofile but i didnt know how i can begin

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #26721

    Hi Jennifer,

    No, Not that.

    I was referring to this.

    1. Keep the values in array e.g $val = array(“OPT1”, “OPT2”);
    2. Then serializing it using something like this $serialized = maybe_searialize($val).

    Then you can store that value.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26722

    HI! Can I serialize it if the form format is based on repeater fields? that is, I don’t have the number of options to put in the array.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #26723

    Hi Jennifer,
    I was referring for the BuddyPress core multi fields(checkbox/select).

    You are most probably using a custom implementation for the repeater field. Please consult the developer on how to store it in the database. It may have a different strategy for storing.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26725

    Thanks Brajesh! i hope resolve it! Regards!

You must be logged in to reply to this topic.

This topic is: not resolved