| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template used to display form fields with multiple checkboxes. |
| 4 |
* |
| 5 |
* @author WP Charitable LLC |
| 6 |
* @package Charitable/Templates/Form Fields |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
$form = $view_args['form']; |
| 16 |
$field = $view_args['field']; |
| 17 |
$classes = $view_args['classes']; |
| 18 |
$is_required = isset( $field['required'] ) ? $field['required'] : false; |
| 19 |
$options = isset( $field['options'] ) ? $field['options'] : array(); |
| 20 |
$value = isset( $field['value'] ) ? (array) $field['value'] : array(); |
| 21 |
|
| 22 |
if ( empty( $options ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
?> |
| 26 |
<div id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>" class="<?php echo $classes; ?>"> |
| 27 |
<fieldset class="charitable-fieldset-field-wrapper"> |
| 28 |
<?php if ( isset( $field['label'] ) ) : ?> |
| 29 |
<div class="charitable-fieldset-field-header" id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_label"> |
| 30 |
<?php echo $field['label']; ?> |
| 31 |
<?php if ( $is_required ) : ?> |
| 32 |
<abbr class="required" title="required">*</abbr> |
| 33 |
<?php endif ?> |
| 34 |
</div> |
| 35 |
<?php endif ?> |
| 36 |
<ul class="charitable-checkbox-list options"> |
| 37 |
<?php foreach ( $options as $val => $label ) : ?> |
| 38 |
<li> |
| 39 |
<input type="checkbox" |
| 40 |
id="<?php echo esc_attr( $field['key'] . '-' . $val ); ?>" |
| 41 |
name="<?php echo $field['key']; ?>[]" |
| 42 |
value="<?php echo $val; ?>" |
| 43 |
aria-describedby="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_label" |
| 44 |
<?php checked( in_array( $val, $value ) ); ?> |
| 45 |
<?php echo charitable_get_arbitrary_attributes( $field ); ?> /> |
| 46 |
<label for="<?php echo esc_attr( $field['key'] . '-' . $val ); ?>"><?php echo $label; ?></label> |
| 47 |
</li> |
| 48 |
<?php endforeach ?> |
| 49 |
</ul> |
| 50 |
</fieldset> |
| 51 |
</div> |
| 52 |
|