예제 #1
0
파일: test.php 프로젝트: pv/Tableau
    $tableau->add_validator('birthdate', value_required);
    // Then, we specify a display filter function, that adds
    // "missing"-links to fields whose values are missing.
    function mark_missing($row, $field, &$disp, &$cell_attr)
    {
        // Note that $field == null indicates the first column,
        // which contains an 'edit row' link
        if ($field == "changes") {
            return;
        }
        if ($field and !$row[$field]) {
            $disp = "<a href=\"?action=edit&id=" . $row['id'] . "\">(missing)</a>";
            $cell_attr['style'] = 'background-color: red; color: white;';
        }
    }
    $tableau->add_callback('display', mark_missing);
    // Indicate that we want to sort according to name, and in
    // ascending order
    $tableau->set_default_sort('name', 0);
    // We are now set and done, let's display the table component
    $tableau->display();
} else {
    if ($_GET['table'] == 'responsibilities') {
        print "<div class='linkbox'><span><a href=\"?table=staff\">Staff</a></span> <span><b>Responsibilities</b></span>{$linkbox_other_links}</div>";
        // This is the specification for the second table,
        // which goes quite in the same way as previously.
        $tableau = new Tableau($connection, 'responsibilities');
        $tableau->set_columns('id', new Tableau_IDColumn(), 'name', new Tableau_ForeignKeyColumn($connection, 'staff', 'name', 'name'), 'responsibility', new Tableau_ChoiceColumn(array('watering plants', 'making fires', 'calling fire brigade')));
        $tableau->set_name('id', 'ID', 'name', 'Name', 'responsibility', 'Responsibility');
        $tableau->set_comment('responsibility', 'What this guy or gal should do?');
        $tableau->add_validator('name', value_required);