Search code examples
arrayscheckboxphpbbphpbb3

Can't get checkbox array with phpBB 3.3's Request class


I have a POST form with the following checkboxes generated in a loop by PHP:

echo '<input class="form-check-input" type="checkbox" name="delist_ids[]" value="'.$row['id'].'" aria-label="Delist blacklisted server">';

Then on submit I'm trying to get the array containing the user's checked boxes (delist_ids). I'm using the Request class in the newest phpBB:

$delist_ids = $request->variable('delist_ids', array(), true, \phpbb\request\request_interface::POST);

But it just returns the default empty array. How can I get it to return the checked boxes' id?


Solution

  • I reached out to phpBB and a guy from their team (paul999) pointed out what I'm doing wrong.

    Apparently I was supposed to set values in the default entry (where my array() is), so the working code is:

    $delist_ids = $request->variable('delist_ids', [0 => 0], false, \phpbb\request\request_interface::POST);