fix: save per-category menus via dedicated endpoint, not the main form

The main form exceeded max_input_vars (27 flows × 37 fields each) so PHP
silently dropped per_type_menu before reaching the save handler.

- Add POST /admin/bot-config/save-per-type — reads existing DB config,
  merges only the per_type_menu values, saves back
- Per-type selects fire savePerType() onchange → AJAX → toast on success
- Add public/.user.ini with max_input_vars=5000 as belt+suspenders
- Remove array_is_list() (PHP 8.1) — replaced with PHP 7.4 compatible check

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-30 19:06:13 -05:00
co-authored by Claude Sonnet 4.6
parent cae448a9c6
commit 8f51659f1e
3 changed files with 57 additions and 1 deletions
+22 -1
View File
@@ -2917,7 +2917,7 @@ HTML;
<div style="font-weight:700;font-size:13px;color:#0b3d91;margin-bottom:12px">{$label}</div>
<div class="form-group" style="margin-bottom:0">
<label>Menú de bienvenida (greeting menu)</label>
<select name="per_type_menu[{$cat}]" style="width:100%;padding:9px 12px;border:1px solid #e2e5ea;border-radius:8px;font-size:13px">
<select name="per_type_menu[{$cat}]" onchange="savePerType()" style="width:100%;padding:9px 12px;border:1px solid #e2e5ea;border-radius:8px;font-size:13px">
{$opts}
</select>
<div style="font-size:11px;color:#7a8291;margin-top:4px">Menú que se muestra cuando el usuario escribe por primera vez o sin contexto activo</div>
@@ -3491,6 +3491,27 @@ HTML;
const CONFIG = {$botConfigJson};
const ENDPOINTS = {$botEndpointsJson};
function savePerType() {
const fd = new FormData();
fd.set('company_id', COMPANY_ID);
[1, 2, 3].forEach(cat => {
const sel = document.querySelector('select[name="per_type_menu[' + cat + ']"]');
if (sel) fd.append('per_type_menu[' + cat + ']', sel.value);
});
fetch('/admin/bot-config/save-per-type', { method: 'POST', body: fd })
.then(r => r.json())
.then(d => {
if (d.ok) {
const t = document.createElement('div');
t.className = 'toast toast-success';
t.textContent = '✅ Categorías guardadas';
t.style.cssText = 'position:fixed;bottom:24px;right:24px;z-index:9999;padding:10px 18px;border-radius:8px;background:#166534;color:#fff;font-size:13px;font-weight:600';
document.body.appendChild(t);
setTimeout(() => t.remove(), 2500);
}
});
}
function switchTab(tab, btn) {
document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-btn').forEach(t => t.classList.remove('active'));