Results 1 to 1 of 1

Thread: Saving multiple checkboxes output as Array

  1. #1
    Thread Starter
    Veteran vienna's Avatar
    Join Date
    May 2010
    Location
    Vienna, Austria
    Posts
    718
    Thanks
    19
    Thanked 177 Times in 118 Posts

    Saving multiple checkboxes output as Array

    I have modified the Custom forms in the step-functions.php to give me a Checkbox option and, for now, have this code

    case 'checkbox':
    ?>
    <?php $options = explode(',', $result->field_values);
    foreach ($options as $option)
    {
    ?>
    <input type="<?php echo $result->field_type; ?>" name="<?php echo $result->field_name; ?>[]" value="<?php if($result->field_req) echo 'required'?><?php echo $option; ?>" multiple="yes"><?php echo $option; ?><br>

    <?php
    }
    ?>
    <div class="clr"></div>
    <?php
    break;

    When the form is posted in a new ad I want the checked values saved in an ARRAY that winds up in the wp_postmeta table in the meta_value field as a comma separated array such as "Jacuzzi, sauna, heated pool..."

    Then I will pull out the values into a list. I have already made the function that does this--pull a comma-separated array into a list and just from custom checkbox values. I see that it must be jsquery that highlights the chosen checkbox arrays when the ad is first reviewed.

    I have tried multiple methods to make the array happen...that after an ad is Submitted the multiple values that are normally appended in such a checkbox in html would be passed along in the browser url.

    Supposedly, the [] added to the name value inside the input code will "cause" php to make its own array when the name for each input field is the same, as in name="custom_checkbox_1[]"... I also added multiple="yes" to signify that that multiple values are expected and allowed.

    This does not work when the values are being grabbed with php functions, however.

    And I have tried methods in the step2.php and in step-functions.php, everything from serialize to implode, to pre-counting array methods.

    My experiments have given me too many php errors or empty arrays.

    Any suggestions on the slickest method?

    Thanks for your kind help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Saving Customized Theme for multiple uploads
    By joshthomas80 in forum ClassiPress General Discussion
    Replies: 6
    Last Post: July 13th, 2009, 03:24 PM