| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* @since 3.0 |
| 8 |
*/ |
| 9 |
class FrmFieldCheckbox extends FrmFieldType { |
| 10 |
|
| 11 |
/** |
| 12 |
* @var string |
| 13 |
* |
| 14 |
* @since 3.0 |
| 15 |
*/ |
| 16 |
protected $type = 'checkbox'; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var bool |
| 20 |
* |
| 21 |
* @since 3.0 |
| 22 |
*/ |
| 23 |
protected $holds_email_values = true; |
| 24 |
|
| 25 |
/** |
| 26 |
* Does the html for this field label need to include "for"? |
| 27 |
* |
| 28 |
* @var bool |
| 29 |
* |
| 30 |
* @since 3.06.01 |
| 31 |
*/ |
| 32 |
protected $has_for_label = false; |
| 33 |
|
| 34 |
/** |
| 35 |
* @return string |
| 36 |
*/ |
| 37 |
protected function input_html() { |
| 38 |
return $this->multiple_input_html(); |
| 39 |
} |
| 40 |
|
| 41 |
protected function include_form_builder_file() { |
| 42 |
return $this->include_front_form_file(); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* @return bool[] |
| 47 |
*/ |
| 48 |
protected function field_settings_for_type() { |
| 49 |
return array( |
| 50 |
'invalid' => true, |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* @return string[] |
| 56 |
*/ |
| 57 |
protected function new_field_settings() { |
| 58 |
return array( |
| 59 |
'options' => serialize( |
| 60 |
array( |
| 61 |
__( 'Option 1', 'formidable' ), |
| 62 |
__( 'Option 2', 'formidable' ), |
| 63 |
) |
| 64 |
), |
| 65 |
); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Get the type of field being displayed. |
| 70 |
* |
| 71 |
* @since 4.02.01 |
| 72 |
* |
| 73 |
* @param array|object $field |
| 74 |
* |
| 75 |
* @return array |
| 76 |
*/ |
| 77 |
public function displayed_field_type( $field ) { |
| 78 |
return array( |
| 79 |
$this->type => true, |
| 80 |
); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* @return array |
| 85 |
*/ |
| 86 |
protected function extra_field_opts() { |
| 87 |
return array( |
| 88 |
'align' => '', |
| 89 |
); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* @since 4.06 |
| 94 |
* |
| 95 |
* @param array $args |
| 96 |
* |
| 97 |
* @return void |
| 98 |
*/ |
| 99 |
protected function show_priority_field_choices( $args = array() ) { |
| 100 |
include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-images.php'; |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* @return string |
| 105 |
*/ |
| 106 |
protected function include_front_form_file() { |
| 107 |
return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/checkbox-field.php'; |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* @return bool |
| 112 |
*/ |
| 113 |
protected function show_readonly_hidden() { |
| 114 |
return true; |
| 115 |
} |
| 116 |
|
| 117 |
protected function prepare_import_value( $value, $atts ) { |
| 118 |
return $this->get_multi_opts_for_import( $value ); |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* Unset aria-invalid for checkboxes because it's not valid for checkboxes. |
| 123 |
* Instead aria-invalid is added to the checkbox group parent element. |
| 124 |
* |
| 125 |
* @since 6.25 |
| 126 |
* |
| 127 |
* @param array $shortcode_atts |
| 128 |
* @param array $args |
| 129 |
*/ |
| 130 |
public function set_aria_invalid_error( &$shortcode_atts, $args ) { |
| 131 |
unset( $shortcode_atts['aria-invalid'] ); |
| 132 |
} |
| 133 |
} |
| 134 |
|