Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

AlabamaMike
Copy link

@AlabamaMike AlabamaMike commented Aug 28, 2025

Description

Previously, checkbox fields in PDF templates always displayed as "true" or "false" in English, regardless of the user's language settings. This fix replaces the hardcoded strings with calls to the translate() function using the existing 'checkbox_dom' language list, ensuring checkbox values are properly localized.

Motivation and Context

  • Checkbox values now display as "Yes"/"No" in English
  • Values are properly translated for other installed language packs
  • Administrators can customize these values through language files

How To Test This

  1. Create a PDF Template:
    - Go to Admin → PDF Templates (or AOS → PDF Templates)
    - Click Create PDF Template
    - Select a module that has checkbox fields (e.g., Accounts, Contacts)
    - In the template body, add checkbox field variables like:
    Active Status: $account_active_c
    Email Opt Out: $email_opt_out
    Do Not Call: $do_not_call
  2. Create/Edit a Record:
    - Go to the module you selected (e.g., Accounts)
    - Create or edit a record
    - Set some checkbox fields to checked (Yes) and others unchecked (No)
    - Save the record
  3. Generate the PDF:
    - Open the record you created
    - Click Actions → Print as PDF
    - Select your template
    - Generate the PDF
  4. Verify Results:
    - Checkbox values should show as "Yes" or "No" (in English)
    - Not as "true", "false", "1", or "0"
    - If using other languages, should show localized values

Types of changes

[ X] Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

[ X] My code follows the code style of this project found here.

  • My change requires a change to the documentation.
    [X ] I have read the How to Contribute guidelines.

Previously, checkbox fields in PDF templates always displayed as "true" or "false"
in English, regardless of the user's language settings. This fix replaces the
hardcoded strings with calls to the translate() function using the existing
'checkbox_dom' language list, ensuring checkbox values are properly localized.

- Checkbox values now display as "Yes"/"No" in English
- Values are properly translated for other installed language packs
- Administrators can customize these values through language files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 15:40
@SuiteBot
Copy link

SuiteBot commented Aug 28, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes checkbox field localization in PDF templates by replacing hardcoded "true"/"false" strings with translatable values using the existing 'checkbox_dom' language list.

  • Replaces hardcoded "true" string with translate() call for checked checkboxes
  • Replaces hardcoded "false" string with translate() call for unchecked checkboxes
  • Uses existing 'checkbox_dom' translation keys for consistent localization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

} elseif ($field_def['type'] == 'bool') {
if ($focus->{$fieldName} == "1") {
$repl_arr[$key . "_" . $fieldName] = "true";
$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '1');
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translate() function calls use magic string keys '1' and '2' without clear documentation of what these keys represent in the checkbox_dom translation list. Consider adding comments to clarify that '1' represents the checked state and '2' represents the unchecked state, or use named constants for better maintainability.

Copilot uses AI. Check for mistakes.

$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '1');
} else {
$repl_arr[$key . "_" . $fieldName] = "false";
$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '2');
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translate() function calls use magic string keys '1' and '2' without clear documentation of what these keys represent in the checkbox_dom translation list. Consider adding comments to clarify that '1' represents the checked state and '2' represents the unchecked state, or use named constants for better maintainability.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants