Results 1 to 2 of 2

Thread: Custom Fields -- Need to save that array NOW, pretty please

  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

    Custom Fields -- Need to save that array NOW, pretty please

    Since my desire line with ClassiPress absolutely mandates that it have the ability to use multiple checkboxes in the forms and no hope for this has been offered for 3.0.3 I have been forced to mod files to give me the ability to make checkboxes that are meant to hold an array of values if more than one checkbox is selected.

    But I have beaten my head against the wall for over two weeks trying to get ClassiPress to save just one array around the step2 action. I can see the array when I echo or print but every method for passing an array that I have used in the past in other php programs fails with ClassiPress! Every single method, ad infinitum.

    It ought to be simple but it is way beyond me. So, I am looking for some developer help.

    I need to move on and get my site running and I have come into the forum and asked this question several times.

    I need FORUM SUPPORT with a method that works with CP...not a theoretical that works generically in PHP. I have written up the ying yang with those.

    My present code generates the array of checked values I need and outputs them because I have tested and they show up when I print or echo the output.

    But getting just the value array to pass along as one $meta_value string is not happening.

    In step2.php I see this--

    // put all the posted form values into session vars
    foreach($_POST as $key => $value)
    $postvals[$key] = cp_clean($value);

    apparently here I need to get the string of value 1,value2,value3...inserted into the full array of $postvals that gets saved as a long, long array

    this code is what gets filled in to create whatever number of multiple checkboxes where the name="cp_checkbox_amenities" may wind up being 5 boxes of which a user may check from none to all 5.

    But, another part of the form may produce a checkbox such as "cp_checkbox_community" with six values as options. whatever....

    <?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; ?>"><?php echo $option; ?><br>

    <?php
    }

    I know that the ad info is first saved in table wp_options in the "option_value" field as one huge array that contains everything in the form after it is first submitted.

    When the ad returns for the user to check the values before agreeing to terms and hitting the final submit it here that my form must already display whatever checkbox values were selected. I know the arrays are being created from my print or echo tests. But unfortunately not passed into the $postvals array.

    When the ad is finally saved in either step 3 or 4 this huge string will be parsed out and put into table wp_postmeta and the "meta_key" field will hold the name of the field, such as 'cp_checkbox_amenities' and the "meta_value" field will hold the final array string, such as "Jacuzzi,Sauna,Exercize Gym"

    So, the critical first step is in step2.php around line 45 when the postvals now collect the input field values.

    I need to distinguish the string wtih either type="checkbox" or where the cp_string_starts_with "cp_checkbox_" (because other custom multiple input fields will start with cp_checkbox_)

    and at this point start the comma delimited array that stays together as one string value that winds up later inserted into the "meta_value" field.

    There is not an "idea that ought to work" (iteration, implode/explode, various string arrays, etc, that I have not seen or tried repeatedly over the past weeks.

    So, I definitely NEED the ClassiPress function method!

    Thanks for a Professional solution!!

  2. #2
    Thread Starter
    Veteran vienna's Avatar
    Join Date
    May 2010
    Location
    Vienna, Austria
    Posts
    718
    Thanks
    19
    Thanked 177 Times in 118 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Saving multiple checkboxes output as Array
    By vienna in forum ClassiPress General Discussion
    Replies: 0
    Last Post: July 16th, 2010, 11:06 AM
  2. Can't Save Edit Ad Internet Explorer
    By Jaapaap in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: July 1st, 2010, 08:44 PM
  3. Custom Fields
    By Skelbimai in forum Help Using ClassiPress
    Replies: 2
    Last Post: April 3rd, 2010, 11:16 AM