PluginProbe
Hash Form – Drag & Drop Form Builder / trunk
Hash Form – Drag & Drop Form Builder vtrunk
1.4.4 1.4.3 1.4.2 1.4.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.6.1 1.2.7 1.2.8 1.2.9 1.3.0 All 47 releases
hash-form / includes / fields / HashFormFieldCheckbox.php

HashFormFieldCheckbox.php in Hash Form – Drag & Drop Form Builder trunk, at includes/fields/HashFormFieldCheckbox.php

44 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || die();
3
4 class HashFormFieldCheckbox extends HashFormFieldType {
5
6 protected $type = 'checkbox';
7
8 public function field_settings_for_type() {
9 return array(
10 'default' => false,
11 );
12 }
13
14 protected function extra_field_default_opts() {
15 return array(
16 'options_layout' => 'inline',
17 );
18 }
19
20 protected function input_html() {
21 $field = $this->get_field();
22 $options = $field['options'] ? $field['options'] : array();
23 $default = $field['default_value'] && is_array($field['default_value']) ? $field['default_value'] : array();
24 ?>
25 <div class="hf-choice-container">
26 <?php
27 foreach ($options as $option_key => $option) {
28 $label = isset($option['label']) ? $option['label'] : '';
29 ?>
30 <div class="hf-choice hf-checkbox">
31 <label for="<?php echo esc_attr($this->html_id('-' . $option_key)); ?>">
32 <input type="checkbox" id="<?php echo esc_attr($this->html_id('-' . $option_key)) ?>" name="<?php echo esc_attr($this->html_name()) . '[]'; ?>" value="<?php echo esc_attr($label); ?>" <?php checked(in_array($label, $default), true); ?> />
33 <?php echo esc_html($label); ?>
34 </label>
35 </div>
36 <?php
37 }
38 ?>
39 </div>
40 <?php
41 }
42
43 }
44