Skip to content

Commit b1acdad

Browse files
tellthemachinesmatticbot
authored andcommitted
Fix forms input placeholder displaying when its value is "0" (#42173)
* Fix forms input placeholder displaying when its value is "0" * changelog * Check if placeholder is null Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/14026333964 Upstream-Ref: Automattic/jetpack@9ab420d
1 parent f06356d commit b1acdad

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This is an alpha version! The changes listed here are not final.
1515

1616
### Fixed
1717
- Components: Add __next40pxDefaultSize to controls, preventing deprecation notices.
18+
- Placeholder should always display if it's a non-empty string
1819

1920
## [0.43.0] - 2025-03-18
2021
### Added

src/contact-form/class-contact-form-field.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1066,14 +1066,14 @@ public function render_field( $type, $id, $label, $value, $class, $placeholder,
10661066

10671067
$form_style = $this->get_form_style();
10681068
if ( ! empty( $form_style ) && $form_style !== 'default' ) {
1069-
if ( empty( $placeholder ) ) {
1069+
if ( ! isset( $placeholder ) || '' === $placeholder ) {
10701070
$placeholder .= ' ';
10711071
} else {
10721072
$class .= ' has-placeholder';
10731073
}
10741074
}
10751075

1076-
$field_placeholder = ( ! empty( $placeholder ) ) ? "placeholder='" . esc_attr( $placeholder ) . "'" : '';
1076+
$field_placeholder = ( '' !== $placeholder ) ? "placeholder='" . esc_attr( $placeholder ) . "'" : '';
10771077
$field_class = "class='" . trim( esc_attr( $type ) . ' ' . esc_attr( $class ) ) . "' ";
10781078
$wrap_classes = empty( $class ) ? '' : implode( '-wrap ', array_filter( explode( ' ', $class ) ) ) . '-wrap'; // this adds
10791079
$has_inset_label = $this->has_inset_label();

0 commit comments

Comments
 (0)