MyBB Community Forums

Full Version: Solved: help with the form class and specifically generate_select_box
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I am looking at making a select box that has a list of categories in them and will be something like


I can generate the basic list using the following

foreach($categories as $category) {
$cat_option[] = $category["name"];

$category_box = $form->generate_select_box('category', $cat_option, $mybb->input['category']);

this will result in a select box with value="0", 1, 2 etc however I want these values to be $category["ID"];

How would I do this? What part of the array or what do I need to build into the array to force the value of each option, not just the display?


I should note that when I put in an associative array of

$category = array("category1" => "category Name 1", "category2" => "category name 2");

The form field fails with an error because the foreach fails


NOTE: ok I fixed this, an associative array is the correct way to handle this, there was a typo in my create select box part Smile