Results 1 to 3 of 3

Thread: Adding tag checkboxes to post-form?

  1. #1
    Thread Starter
    Senior Member herb_'s Avatar
    Join Date
    May 2009
    Posts
    230
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Adding tag checkboxes to post-form?

    I'd like to include specific tags as checkbox choices in the post-form.

    I've tried adding this to post-form.php:

    Code:
    <label for="post_tags"><?php _e('Tags ','cp'); ?></label>
    			<input type="checkbox" name="post_tags" id="post_tags" value="Monday" > Monday
    
    			<input type="checkbox" name="post_tags" id="post_tags" value="Tuesday"> Tuesday
    
    			<input type="checkbox" name="post_tags" id="post_tags" value="Wednesday"> Wednesday
    
    			<input type="checkbox" name="post_tags" id="post_tags" value="Thursday"> Thursday
    But when multiple chechboxes are checked, only the last one in the markup is displayed in the ad post.

    Also, if any checkboxes are checked, this causes any entries to the regular (text) tag input to not be shown in the ad post.

    I tried tweaking some things in form_process, but to no avail.

    Any idea how we can do this?

  2. #2
    Founder dcowgill's Avatar
    Join Date
    Mar 2009
    Location
    San Francisco, CA
    Posts
    1,939
    Thanks
    66
    Thanked 135 Times in 99 Posts

    Re: Adding tag checkboxes to post-form?

    Yeah, that's a bit tricky since you are putting the checkboxes in an array by using the same "name" value. That's how you'd have to do it but the receiving end isn't setup to parse the array which is probably why you only get the last value.

    I'd post your question on the wordpress codex and see what those WP gurus have to say. If you get a solution, it would be great if you could share it here.

  3. #3
    Thread Starter
    Senior Member herb_'s Avatar
    Join Date
    May 2009
    Posts
    230
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Adding tag checkboxes to post-form?

    Ok I got the checkbox array working, by switching the name to checkbox_tags[] in post-form.php (the [] distinguishes the name as being an array).... and then including the following in form_process.php:

    $checkbox_tags = ($_POST['checkbox_tags']);

    it was added toward the top of the document, just below: $post_tags = cp_filter($_POST['post_tags']);



    and changing tags_input to be associated with $checkbox_tags instead of $post_tags in form_process.php:

    'tags_input' => $checkbox_tags


    Only issue is how to pool $post_tags and $checkbox_tags so they can both enter into tags_input.

    Another option, if wanting to still allow typed-in tags, is make several separate tag text input fields of the same array as the checkboxes (using the same name checkbox_tags[] - or switching all back to a more generic name), then not worry about dealing with commas (likely what I'll do). Then a user can choose from the checkbox tags, and also type in 3 unique tags in the separate input fields (or however many you want to allow). I may post a tutorial once I decide what I'll be doing.

Thread Information

Users Browsing this Thread

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