Nefunguje Checkbox v HTML, proč?
Ahoj, mám formulář s checboxem, který nefunguje, a nedokážu přijít na to, proč.
Kód:
//vypis tabulky
echo "
<div class=\"row mt-1 align-items-center $danger\" style=\"background-color: #88c7ff08;\">
<div class=\"col-lg-1\">
<input class=\"form-control form-control-sm form_firm\" type=\"checkbox\" name=\"nabrouseno_ok[]\" value=\"lala\">
</div>
<div class=\"col-lg-2\">".$all_types."</div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm form_firm\" type=\"text\" name=\"firm\" value=\"".$row['firm']."\" class=\"form_firm\" readonly></div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm form_product\" type=\"text\" name=\"product\" value=\"".$row['product']."\" class=\"form_product\" readonly></div>
<div class=\"col-lg-1\"><input class=\"form-control form-control-sm\" type=\"number\" name=\"stock\" value=\"".$row['stock']."\" readonly></div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm\" type=\"text\" name=\"creation_date\" value=\"".date("Y-m-d", strtotime($row['creation_date']))."\" readonly></div>
<div class=\"col-lg-2\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['order_status_id']."\" name=\"order_status_old\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['id']."\" name=\"id\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['ids']."\" name=\"ids\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['note']."\" name=\"note\">
<input type=\"hidden\" name=\"url_to\" value=\"modules/products/edit-product.php\">
<input type=\"hidden\" name=\"url_edit\" value=\"edit-page.php\">
<input type=\"hidden\" name=\"url_from\" value=\"products.php\">
<a href=\"edit-page.php?ids=".$row['ids']."\" class=\"form-control form-control-sm btn btn-secondary btn-block\" role=\"button\">Upravit/Smazat</a>
</div>
</div>
";
po výpisu var_dump($_POST) mi to vypíše všechny proměnné, až na nabrouseno_ok (tedy na checkbox). Když "checkbox" změním třeba na "hidden" či "text", už to funguje a normálně se mi to vypíše.
Taky mi to píše: "Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0" a absolutně nechápu, proč. mám post argument o 12 proměnných.
Celá funkce s komletním formulářem zde:
function product_info ($status_id, $conn, $types_for_product, $data_fil) {
/* vypise postupne vsechny produkty daneho statusu
* $status_id - id statusu, ktere se vypise (tridi se zde vsep odle kategorii)
* $conn - pripojenik db
* $types_for_product - vypise vsechny firmy kam se posilaji produkty vcetne aktualniho
*/
echo "
<div class=\"row text-center\">
<div class=\"col-lg-1\">Výběr</div>
<div class=\"col-lg-2\">Brusírna</div>
<div class=\"col-lg-2\">Firma</div>
<div class=\"col-lg-2\">Produkt</div>
<div class=\"col-lg-1\">Počet</div>
<div class=\"col-lg-2\">Datum</div>
<div class=\"col-lg-2\">Akce</div>
</div>
";
$result = get_data_from_db($status_id, $conn, $data_fil);
if ($result->num_rows > 0) {
echo "<form action=\"edit-page.php\" method=\"POST\">";
while ($row = $result->fetch_assoc()) {
$all_types = types_for_product($types_for_product, $row);
// obarveni dlouho neaktualizovaneho sloupce
$danger = "bg-light pb-1 pt-1";
$datetime1 = new DateTime(date("Y-m-d", strtotime($row['creation_date'])));
$datetime2 = new DateTime(date("Y-m-d "));
$interval = $datetime1->diff($datetime2);
if ($interval->format('%a') >= 7) { // starsi nez tyden vcetne
$danger = "bg-warning pb-1 pt-1";
}
if ($interval->format('%a') >= 14 OR $status_id == 4) { // starsi net 14 dni vcetne
$danger = "bg-danger pb-1 pt-1";
}
//vypis tabulky
echo "
<div class=\"row mt-1 align-items-center $danger\" style=\"background-color: #88c7ff08;\">
<div class=\"col-lg-1\">
<input class=\"form-control form-control-sm form_firm\" type=\"checkbox\" name=\"nabrouseno_ok[]\" value=\"lala\">
</div>
<div class=\"col-lg-2\">".$all_types."</div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm form_firm\" type=\"text\" name=\"firm\" value=\"".$row['firm']."\" class=\"form_firm\" readonly></div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm form_product\" type=\"text\" name=\"product\" value=\"".$row['product']."\" class=\"form_product\" readonly></div>
<div class=\"col-lg-1\"><input class=\"form-control form-control-sm\" type=\"number\" name=\"stock\" value=\"".$row['stock']."\" readonly></div>
<div class=\"col-lg-2\"><input class=\"form-control form-control-sm\" type=\"text\" name=\"creation_date\" value=\"".date("Y-m-d", strtotime($row['creation_date']))."\" readonly></div>
<div class=\"col-lg-2\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['order_status_id']."\" name=\"order_status_old\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['id']."\" name=\"id\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['ids']."\" name=\"ids\">
<input class=\"form-control form-control-sm\" type=\"hidden\" value=\"".$row['note']."\" name=\"note\">
<input type=\"hidden\" name=\"url_to\" value=\"modules/products/edit-product.php\">
<input type=\"hidden\" name=\"url_edit\" value=\"edit-page.php\">
<input type=\"hidden\" name=\"url_from\" value=\"products.php\">
<a href=\"edit-page.php?ids=".$row['ids']."\" class=\"form-control form-control-sm btn btn-secondary btn-block\" role=\"button\">Upravit/Smazat</a>
</div>
</div>
";
}
// vložení formulářů pro úpravy všech produktů
if ($status_id == 1) {
echo "
<div class=\"row form-group mt-2 pl-2 bg-info pt-1 pb-1 text-white\">
<span>Všechny Zadané produkty pro brusírnu</span>
<select name=\"type\" class=\"form-control-sm form-control col-lg-2 ml-2 mr-2\">
".types_for_product_all($conn)."</select>
<span>vložit do Převzaných produktů.</span>
<input type=\"hidden\" name=\"order_status_old\" value=\"1\">
<input type=\"hidden\" name=\"order_status_new\" value=\"2\">
<input type=\"submit\" name=\"edit_to_prevzato\" formaction=\"modules/products/edit-to-prevzato-product.php\" value=\"Vložit do Převzané produkty a vytvořit seznam\" class=\"ml-2\">
</div>";
}
if ($status_id == 2) {
echo "
<div class=\"row form-group mt-2 pl-2 bg-info pt-1 pb-1 text-white\">
<span>Všechny zaškrtnuté produkty z brusírny vložit do Nabroušených produktů.</span>
<input type=\"hidden\" name=\"order_status_old\" value=\"2\">
<input type=\"hidden\" name=\"order_status_new\" value=\"3\">
<input type=\"submit\" name=\"nabrouseno\" formaction=\"modules/products/edit-to-nabrouseno-products.php\" value=\"Vložit do Nabroušených produktů\" class=\"ml-2\">
</div>
";
}
echo "</form>";
}
}
Umíte poradit? Díky moc! ;)