MyBB Hacks

Full Version: Divide checkbox list into 2 columns?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
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?
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
<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.

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?
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.

Thanks for your help!
Reference URL's