Fix is_mandatory checkbox not saving when unchecked
This commit is contained in:
@@ -1377,6 +1377,7 @@ class Admin {
|
|||||||
<th scope='row'><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></th>
|
<th scope='row'><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
|
<input type='hidden' name='is_mandatory' value='0' />
|
||||||
<input type='checkbox' name='is_mandatory' value='1' <?php checked( $cost ? (bool) $cost->is_mandatory : true, true ); ?> />
|
<input type='checkbox' name='is_mandatory' value='1' <?php checked( $cost ? (bool) $cost->is_mandatory : true, true ); ?> />
|
||||||
<?php echo esc_html__( 'Verpflichtende Position', KGVVM_TEXT_DOMAIN ); ?>
|
<?php echo esc_html__( 'Verpflichtende Position', KGVVM_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class Validator {
|
|||||||
$unit_amount = isset( $data['unit_amount'] ) ? str_replace( ',', '.', wp_unslash( $data['unit_amount'] ) ) : '';
|
$unit_amount = isset( $data['unit_amount'] ) ? str_replace( ',', '.', wp_unslash( $data['unit_amount'] ) ) : '';
|
||||||
$entry_year = $this->sanitize_cost_year( $data );
|
$entry_year = $this->sanitize_cost_year( $data );
|
||||||
$distribution_type = sanitize_key( wp_unslash( isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel' ) );
|
$distribution_type = sanitize_key( wp_unslash( isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel' ) );
|
||||||
$is_mandatory = isset( $data['is_mandatory'] ) ? (bool) $data['is_mandatory'] : true;
|
$is_mandatory = isset( $data['is_mandatory'] ) && '1' === (string) wp_unslash( $data['is_mandatory'] );
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'entry_year' => $entry_year,
|
'entry_year' => $entry_year,
|
||||||
|
|||||||
Reference in New Issue
Block a user