Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Divide checkbox list into 2 columns?
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #1
Divide checkbox list into 2 columns?
A bit embarrassing to ask, it seems like it should be very simple, but I'm having a hard time to get it to work without blank lines etc. Any advice?
07-19-2011 11:34 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Divide checkbox list into 2 columns?
Would you be able to give more detail?
Methinks a simple <table> would do the job...

EDIT: I was wondering why you posted this in the XThreads forum - do you mean the checkbox thread field type?  Unfortunately, it's slightly tricky - you've got to hide the input field and then put the HTML into the template.

My Blog
(This post was last modified: 07-19-2011 12:18 PM by ZiNgA BuRgA.)
07-19-2011 12:13 PM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #3
RE: Divide checkbox list into 2 columns?
Yes I do mean checkbox field type. I thought I could do it in the list since it says it accepts HTML input. Any tips?
07-20-2011 02:43 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Divide checkbox list into 2 columns?
Unfortunately, you're going to need template edits for that.  Set Hide Input Field to yes and construct the appropriate table rows into your newthread and editpost_first templates. (prefix appropriately if you're using a template prefix)
Very vague HTML structure:

HTML Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<tr>
<td><strong>My Checkbox Field</strong></td>
<td>
<table>
<tr>
<td><label><input type="checkbox" name="xthreads_my_checkbox_field1" value="1" /> Checkbox 1</label></td>
<td><label><input type="checkbox" name="xthreads_my_checkbox_field2" value="1" /> Checkbox 2</label></td>
</tr>
<tr>
<td><label><input type="checkbox" name="xthreads_my_checkbox_field3" value="1" /> Checkbox 3</label></td>
<td><label><input type="checkbox" name="xthreads_my_checkbox_field4" value="1" /> Checkbox 4</label></td>
</tr>
</table>
</td>
</tr>


The HTML in the values list is probably a bit different to what you want.  It allows you to have something like:

Code:
Item 1
Item 2 <i>(rare item)</i>

...and thus not meant to change structure.

Hope that helps.


My Blog
(This post was last modified: 07-20-2011 09:34 AM by ZiNgA BuRgA.)
07-20-2011 09:33 AM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #5
RE: Divide checkbox list into 2 columns?
Thanks!

How do I connect it to custom thread fields though? I'm likely missing something obvious, but don't I have to use tfinput or something?
07-20-2011 11:16 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: Divide checkbox list into 2 columns?
You just have to ensure the name/value of the fields is appropriate.

For example, if the key is my_field and values are:

Code:
Option 1
Option 2
Option 3

All checkboxes should have a name of xthreads_my_field[] and values as shown above, such as

HTML Code
<input type="checkbox" name="xthreads_my_field[]" value="Option 1" />
<input type="checkbox" name="xthreads_my_field[]" value="Option 2" />
<input type="checkbox" name="xthreads_my_field[]" value="Option 3" />


I just noticed an issue though: it won't show whether they're checked or not. :/


If you don't mind code edits and want to change the underlying HTML, it's in inc/xthreads/xt_updatehooks.php:

PHP Code:
					if(xthreads_empty($val) && $tf['editable'] != XTHREADS_EDITABLE_REQ)
						$tfinput[$k] .= '<label style="display: block; font-style: italic;"><input'.$tfname.' type="'.$tftype.'" class="'.$tftype.'" value=""'.$checked.$tabindex.' />'.$lang->xthreads_val_blank.'</label>';
					else
						$tfinput[$k] .= '<label style="display: block;"><input'.$tfname.' type="'.$tftype.'" class="'.$tftype.'" value="'.$val.'"'.$checked.$tabindex.' />'.unhtmlentities($val).'</label>';

First instance is just for the "blank value".  Note that it affects both checkboxes and optionbutton inputs.
I'll consider exporting this to a template in a future version.


My Blog
(This post was last modified: 07-20-2011 11:53 AM by ZiNgA BuRgA.)
07-20-2011 11:45 AM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #7
RE: Divide checkbox list into 2 columns?
Thanks for your help!
07-27-2011 09:11 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: