| @@ -244,8 +244,9 @@ | ||
| 244 | 244 | // Guard: never persist orphan fields (in fields but in no layout) — they |
| 245 | 245 | // render nothing yet their validation rules block submission. Covers old |
| 246 | 246 | // clients and hand-edited imports (importAForm funnels through here). |
| 247 | 247 | $this->pruneOrphanFields($fields, $nestedLayout, $layout, null, $post); |
| 248 | + FormManager::syncCompositeChildNames($fields); | |
| 248 | 249 | $form_content = [ |
| 249 | 250 | 'fields' => $fields, |
| 250 | 251 | 'layout' => $layout, |
| 251 | 252 | 'nestedLayout' => $nestedLayout, |
| @@ -524,8 +525,12 @@ | ||
| 524 | 525 | $updated_data['form_content']['is_default'] = 1; |
| 525 | 526 | } |
| 526 | 527 | $updated_data['message'] = __('Form Saved successfully', 'bit-form'); |
| 527 | 528 | |
| 529 | + // Form and dependent rows are persisted; multilingual providers register | |
| 530 | + // the form's translatable strings here. | |
| 531 | + do_action('bitform_form_saved', $save_status); | |
| 532 | + | |
| 528 | 533 | return $updated_data; |
| 529 | 534 | } |
| 530 | 535 | } |
| 531 | 536 | |
| @@ -584,8 +589,9 @@ | ||
| 584 | 589 | } |
| 585 | 590 | |
| 586 | 591 | // Guard: never persist orphan fields (see createNewForm). Fail closed. |
| 587 | 592 | $this->pruneOrphanFields($fields, $nestedLayout, $layout, $formID, $post); |
| 593 | + FormManager::syncCompositeChildNames($fields); | |
| 588 | 594 | |
| 589 | 595 | $form_content = [ |
| 590 | 596 | 'fields' => $fields, |
| 591 | 597 | 'layout' => $layout, |
| @@ -797,8 +803,11 @@ | ||
| 797 | 803 | } |
| 798 | 804 | $form_content = array_merge($form_content, ['workFlowExist' => $workFlowExist]); |
| 799 | 805 | //wrokFlows [end] |
| 800 | 806 | //reports [start] */ |
| 807 | + // read unconditionally after the reports block; a save without currentReport | |
| 808 | + // must not trip an undefined-variable warning | |
| 809 | + $reportIsDefault = null; | |
| 801 | 810 | if (!empty($reports)) { |
| 802 | 811 | $reportsModel = new ReportsModel(); |
| 803 | 812 | $fieldNames = []; |
| 804 | 813 | foreach ($fields as $key => $field) { |
| @@ -933,8 +942,12 @@ | ||
| 933 | 942 | } |
| 934 | 943 | if (2 === $newData['reports']) { |
| 935 | 944 | $errorIN .= empty($errorIN) ? 'reports' : ', reports'; |
| 936 | 945 | } |
| 946 | + // See createNewForm(). Fired before the partial-failure return: the rows | |
| 947 | + // that did save are already persisted, so their strings still need registering. | |
| 948 | + do_action('bitform_form_saved', $formId); | |
| 949 | + | |
| 937 | 950 | if (!empty($errorIN)) { |
| 938 | 951 | /* translators: %s: comma-separated list of areas where error occurred */ |
| 939 | 952 | $updated_data['message'] = sprintf(__('Error Occured in saving %s', 'bit-form'), $errorIN); |
| 940 | 953 | return new WP_Error('Form update Error.', $updated_data); |
| @@ -942,8 +955,9 @@ | ||
| 942 | 955 | if (null !== $reportIsDefault) { |
| 943 | 956 | $updated_data['form_content']['is_default'] = $reportIsDefault; |
| 944 | 957 | } |
| 945 | 958 | $updated_data['message'] = __('Form updated successfully.', 'bit-form'); |
| 959 | + | |
| 946 | 960 | return $updated_data; |
| 947 | 961 | } |
| 948 | 962 | } |
| 949 | 963 | |
| @@ -1151,9 +1165,9 @@ | ||
| 1151 | 1165 | 'title' => $emailTemplatevalue->title, |
| 1152 | 1166 | 'sub' => $emailTemplatevalue->sub, |
| 1153 | 1167 | 'body' => $emailTemplatevalue->body, |
| 1154 | 1168 | 'status' => isset($emailTemplatevalue->status) ? (int) $emailTemplatevalue->status : 1, |
| 1155 | - 'config' => !empty($emailTemplatevalue->config) ? json_decode($emailTemplatevalue->config) : (object) [], | |
| 1169 | + 'config' => EmailTemplateHandler::normalizeConfig($emailTemplatevalue->config ?? null), | |
| 1156 | 1170 | ]; |
| 1157 | 1171 | } |
| 1158 | 1172 | } |
| 1159 | 1173 | // get all pdf template |
| @@ -1448,9 +1462,9 @@ | ||
| 1448 | 1462 | 'title' => $emailTemplatevalue->title, |
| 1449 | 1463 | 'sub' => $emailTemplatevalue->sub, |
| 1450 | 1464 | 'body' => $emailTemplatevalue->body, |
| 1451 | 1465 | 'status' => isset($emailTemplatevalue->status) ? (int) $emailTemplatevalue->status : 1, |
| 1452 | - 'config' => !empty($emailTemplatevalue->config) ? json_decode($emailTemplatevalue->config) : (object) [], | |
| 1466 | + 'config' => EmailTemplateHandler::normalizeConfig($emailTemplatevalue->config ?? null), | |
| 1453 | 1467 | ]; |
| 1454 | 1468 | } |
| 1455 | 1469 | } |
| 1456 | 1470 | $integrationHandler = new IntegrationHandler($formID); |
| @@ -2477,10 +2491,15 @@ | ||
| 2477 | 2491 | $layout = $formContent->layout; |
| 2478 | 2492 | foreach ($form_fields as $key => $value) { |
| 2479 | 2493 | // $field_name = preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\!]/', '_', $value->lbl); |
| 2480 | 2494 | if (isset($entries[$key])) { |
| 2481 | - $form_fields->{$key}->val = $entries[$key]; | |
| 2495 | + $isPassword = isset($value->typ) && 'password' === $value->typ; | |
| 2496 | + // Never hand a stored password back to the browser; blank keeps it on update. | |
| 2497 | + $form_fields->{$key}->val = $isPassword ? '' : $entries[$key]; | |
| 2482 | 2498 | $form_fields->{$key}->name = $key; |
| 2499 | + if ($isPassword && '' !== (string) $entries[$key] && isset($value->valid) && is_object($value->valid)) { | |
| 2500 | + $form_fields->{$key}->valid->req = false; | |
| 2501 | + } | |
| 2483 | 2502 | } |
| 2484 | 2503 | } |
| 2485 | 2504 | $workFlowRunHelper = new WorkFlow($formID); |
| 2486 | 2505 | $workFlowreturnedOnLoad = $workFlowRunHelper->executeOnLoad( |