Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms: Fixes checkbox checked state for admins #40847

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/fix-checkbox-checked-state
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Form: fix the default checkstate for admins
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
$field .= "\n<div {$block_style} {$shell_field_class} >\n"; // new in Jetpack 6.8.0

// If they are logged in, and this is their site, don't pre-populate fields
if ( current_user_can( 'manage_options' ) ) {
if ( current_user_can( 'manage_options' ) && isset( $type ) && $type !== 'checkbox' ) {
$value = '';
}

Expand Down Expand Up @@ -1069,7 +1069,7 @@
$field .= $this->render_consent_field( $id, $field_class );
break;
default: // text field
$field .= $this->render_default_field( $id, $label, $value, $field_class, $required, $required_field_text, $field_placeholder, $type );

Check failure on line 1072 in projects/packages/forms/src/contact-form/class-contact-form-field.php

View workflow job for this annotation

GitHub Actions / Static analysis

TypeError PhanTypeMismatchArgumentNullable Argument 8 ($type) is $type of type ?string but \Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field::render_default_field() takes string defined at src/contact-form/class-contact-form-field.php:892 (expected type to be non-nullable)
break;
}

Expand Down
Loading