Welcome Guest, Not a member yet? Register   Sign In
Form Helper: Hidden Input and Validation: Checkbox Arrays
#1

[eluser]aBoy[/eluser]
Hi. I've been using CI for about three months now. It is excellent, thank you very much. Big Grin

I got some issues so I searched the forum for a while, but still have a couple of questions about the Form Helper class.

1. Is there a way to assign an 'id' to an input_hidden function call?

2. I have a dynamicly generated array of checkboxes which allows the user to select what category their profile/article will exist in. We are only really concerned with the last 6 lines or so;

Code:
foreach ($sections as $s) {
    $checked = FALSE;
    if ($start != $s->sectionName) {
        echo "<h4>".$s->sectionName.'</h4>';
        echo "\n";
    }
    // Categories
    $checked = FALSE;
    // Compare users data vs all data
    if (isset($catID)) {
        foreach ($catID as $c) {
            if ($c->catID == $s->catID) {
                $checked = TRUE;
            }
        }
    }
    echo '<div class="indent1">';
    echo form_checkbox(
            'catID[]',
            $s->sectionID.':'.$s->catID,
            $checked,
            $this->validation->set_checkbox('catID[]', $s->sectionID.':'.$s->catID)
            );
    echo $s->catName.'</div>';
    echo "\n";
    $start = $s->sectionName;
}

The line;

Code:
echo form_checkbox(
            'catID[]',
            $s->sectionID.':'.$s->catID,
            $checked,
            $this->validation->set_checkbox('catID[]', $s->sectionID.':'.$s->catID)
            );


containing the piece of code;

Code:
$this->validation->set_checkbox('catID[]', $s->sectionID.':'.$s->catID)

does not work for an array of checkboxes using the same name. Sad The only time this is an issue is if the user creates a 'new' profile/article and misses one of the other required fields. On return to the form all the fields are re-populated except for the checkboxes.

Any ideas?


Messages In This Thread
Form Helper: Hidden Input and Validation: Checkbox Arrays - by El Forum - 05-08-2008, 12:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB