foreach ($_POST['CHECKLIST_ITEM_ID'] as $clId) { if ((string) $_POST['CHECKLIST_ITEM_TITLE'][$clId]) { $id = (string) $clId === (string) intval($clId) ? intval($clId) : false; $data = array('TEMPLATE_ID' => $templateID, 'TITLE' => $_POST['CHECKLIST_ITEM_TITLE'][$clId], 'CHECKED' => $_POST['CHECKLIST_ITEM_IS_CHECKED'][$clId] == 'Y', 'SORT' => $sort++); if (intval($id)) { $data['ID'] = $id; $items[$id] = $data; } else { $items[] = $data; } } } $_POST['CHECKLIST_ITEMS'] = $items; // too bad } $arResult["ERRORS"] = $template->GetErrors(); if (sizeof($arResult["ERRORS"]) == 0) { $arUploadedFils = unserialize($arFields["FILES"]); if (is_array($arUploadedFils) && count($arUploadedFils)) { $userId = (int) $USER->GetID(); foreach ($arUploadedFils as $fileId) { CTaskFiles::removeTemporaryFile($userId, (int) $fileId); } } // add\update check list items here try { \Bitrix\Tasks\Template\CheckListItemTable::updateForTemplate($templateID, $_POST['CHECKLIST_ITEMS']); } catch (\Bitrix\Main\ArgumentException $e) { } if (strlen($_POST["save"]) > 0) { if ((string) $arParams['PATH_TO_TEMPLATES_TEMPLATE'] !== '' && intval($templateID)) {