Skip to content

docs: Clarify that value 0 is valid when setting contact fields via API#297

Draft
promptless-for-oss wants to merge 1 commit intomautic:5.xfrom
Promptless:promptless/pr-15900-zero-value-contact-fields
Draft

docs: Clarify that value 0 is valid when setting contact fields via API#297
promptless-for-oss wants to merge 1 commit intomautic:5.xfrom
Promptless:promptless/pr-15900-zero-value-contact-fields

Conversation

@promptless-for-oss
Copy link

Open this suggestion in Promptless to view citations and reasoning process

Adds a note to the Contacts API documentation explaining that Mautic only treats null and empty strings as empty values. The value 0 (integer or string) is a valid value and will be saved to the field. This clarification helps API developers who need to set numeric fields to zero.

Trigger Events

mautic/mautic PR #15900: fix: use strict comparison for isEmpty to allow saving value 0 in contact fields

Promptless Research (1 GitHub PR)

Agent Response

I've completed my review of PR #15900 and created a documentation update.

Summary

PR #15900 fixes a bug where setting a contact field value to 0 (zero) via the REST API was silently ignored. The root cause was PHP's loose comparison treating 0 as an empty value. With the fix, 0 is now correctly saved as a valid value.

Documentation Update

I created a suggestion that adds a clarifying note to the Contacts API documentation explaining:

  • Only null and empty strings ('') are treated as empty values
  • The value 0 (whether integer or string) counts as a valid value and gets saved
  • This is relevant when using overwriteWithBlank or setting numeric fields to zero

Suggestion: Clarify that value 0 is valid when setting contact fields via API

File updated: docs/rest_api/contacts.rst

This documentation clarification will help API developers understand the expected behavior when working with numeric contact fields and the overwriteWithBlank parameter.


Tip: Use labels in the Promptless dashboard to categorize suggestions by release or team 🏷️

Signed-off-by: promptless-for-oss <promptless-for-oss@users.noreply.github.com>
* - ``overwriteWithBlank``
- If true, then empty values get set to fields. Otherwise empty values get skipped

.. note:: Mautic only treats ``null`` and empty strings (``''``) as empty values. The value ``0`` - whether integer or string - counts as a valid value and gets saved to the field. This matters when using ``overwriteWithBlank`` or setting numeric fields to zero.
Copy link
Author

Choose a reason for hiding this comment

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

Citation: Based on bug fix in LeadModel::setFieldValues() that changed from loose to strict comparison for empty value detection. The PR description explains that null == 0 returned true (buggy) but now null === 0 returns false (correct), allowing 0 to be saved as a valid value.
View source

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.

1 participant