| @@ -38,12 +38,23 @@ | ||
| 38 | 38 | * @since 0.0.1 |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | 41 | public function markup() { |
| 42 | - $classes = $this->get_field_classes(); | |
| 42 | + // `sd-checkbox-field` is this block's own modifier. `sd-checkbox-block` | |
| 43 | + // and the `sd-checkbox-*` element classes are a shared contract — the | |
| 44 | + // anonymous-donation, cover-fees and privacy-consent fields write the | |
| 45 | + // same markup by hand — so anything specific to the authorable field | |
| 46 | + // (styling, and the frontend hooks that read its label and validate it) | |
| 47 | + // keys off this class instead of the shared ones. | |
| 48 | + $classes = $this->get_field_classes( [ 'sd-checkbox-field' ] ); | |
| 43 | 49 | $aria_desc = $this->get_aria_describedby(); |
| 44 | 50 | $required_mark = $this->required ? '<span class="sd-required" aria-hidden="true">*</span>' : ''; |
| 45 | 51 | |
| 52 | + // The slug is the key the value is submitted, validated and stored | |
| 53 | + // under. Without it the field renders but never reaches the server — | |
| 54 | + // the failure mode #273 hit on the anonymous-donation checkbox. | |
| 55 | + $data_slug = $this->block_slug ? $this->block_slug : $this->unique_slug; | |
| 56 | + | |
| 46 | 57 | ob_start(); |
| 47 | 58 | ?> |
| 48 | 59 | <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $classes ); ?>"> |
| 49 | 60 | <div class="sd-block-wrap sd-checkbox-wrap"> |
| @@ -52,8 +63,9 @@ | ||
| 52 | 63 | class="sd-input-checkbox" |
| 53 | 64 | type="checkbox" |
| 54 | 65 | name="<?php echo esc_attr( $this->field_name ); ?>" |
| 55 | 66 | id="<?php echo esc_attr( $this->unique_slug ); ?>" |
| 67 | + data-slug="<?php echo esc_attr( $data_slug ); ?>" | |
| 56 | 68 | value="1" |
| 57 | 69 | <?php if ( ! empty( $aria_desc ) ) { ?> |
| 58 | 70 | aria-describedby="<?php echo esc_attr( $aria_desc ); ?>" |
| 59 | 71 | <?php } ?> |