The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Add Checkboxes to Form
I am trying to add checkboxes to the free agent signup form in the vbTournaments mod. I have created the extra field in the database table and a single selection works without issue. The problem I have is that when multiple checkboxes are selected only the last selection is saved to the database instead of all of the choices.
tmnt_newfreeagent template: HTML Code:
<form class="vbform block" action="teams.php?do=addfreeagent" method="post"> <div class="blockbody formcontrols"> <div class="blockrow"> <label for="game">Game</label> <div style="overflow:auto"> <input type="checkbox" name="game[]" value="Aliens vs. Predator">Aliens vs. Predator<br /> <input type="checkbox" name="game[]" value="Chivalry: Medeival Warfare">Chivalry: Medeival Warfare<br /> <input type="checkbox" name="game[]" value="Counter-Strike: Global Offensive">Counter-Strike: Global Offensive<br /> <input type="checkbox" name="game[]" value="Insurgency">Insurgency<br /> </div> <p class="description">Please select the game(s) you play.</p> </div> </div> <div class="blockfoot actionbuttons"> <div class="group"> <input type="submit" class="button" value="{vb:rawphrase submit}" /> </div> </div> </form> PHP Code:
|
#2
|
||||
|
||||
Try TYPE_ARRAY
Also serialize $game before saving it to the db |
#3
|
|||
|
|||
It's because you're sending an array of values to the server.
$vbulletin->input->clean_array_gpc('p', 'game', TYPE_STR); $vbulletin->GPC['game']; should then contain the games separated by commas. |
#4
|
|||
|
|||
I tried TYPE_ARRAY shortly after posting earlier and just get an error message on submit, no data is sent for that field. Could you please explain or point me in the right direction to "serialize $game" since I'm not familiar with this. I'm a novice when it comes to PHP and my vb experience is even more limited. I'm just trying to teach myself the basics by checking out other mods so any info is useful.
Quote:
Thank you both for the replies. |
#5
|
|||
|
|||
Does anyone have any ideas how to resolve this I've spent a lot of time on this script and fixed everything but this issue. I added regular text fields without issue, I never thought a simple checkbox selection would cause this much trouble. I'm sure the form HTML itself is fine it's just the PHP code handling the submission I'm not sure about.
I tried looking into the serialization of $game but it's over my head. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|