PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.3.0
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.3.0
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / fields / class-field-radio.php

class-field-radio.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.3.0, at includes/fields/class-field-radio.php

118 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Text Field Class
5 */
6 class WeForms_Form_Field_Radio extends WeForms_Form_Field_Checkbox {
7
8 function __construct() {
9 $this->name = __( 'Radio', 'weforms' );
10 $this->input_type = 'radio_field';
11 $this->icon = 'dot-circle-o';
12 }
13
14 /**
15 * Render the text field
16 *
17 * @param array $field_settings
18 * @param integer $form_id
19 *
20 * @return void
21 */
22 public function render( $field_settings, $form_id ) {
23 $selected = isset( $field_settings['selected'] ) ? $field_settings['selected'] : '';
24 ?>
25 <li <?php $this->print_list_attributes( $field_settings ); ?>>
26 <?php $this->print_label( $field_settings, $form_id ); ?>
27
28 <?php do_action( 'weforms_radio_field_after_label', $field_settings ); ?>
29
30 <div class="wpuf-fields" data-required="<?php echo $field_settings['required'] ?>" data-type="radio">
31
32 <?php
33 if ( $field_settings['options'] && count( $field_settings['options'] ) > 0 ) {
34 foreach ($field_settings['options'] as $value => $option) {
35 ?>
36
37 <label <?php echo $field_settings['inline'] == 'yes' ? 'class="wpuf-radio-inline"' : 'class="wpuf-radio-block"'; ?>>
38 <input
39 name="<?php echo $field_settings['name']; ?>"
40 class="<?php echo 'wpuf_'.$field_settings['name']. '_'. $form_id; ?>"
41 type="radio"
42 value="<?php echo esc_attr( $value ); ?>"<?php checked( $selected, $value ); ?>
43 />
44 <?php echo $option; ?>
45 </label>
46 <?php
47 }
48 }
49 ?>
50
51 <?php $this->help_text( $field_settings ); ?>
52
53 </div>
54 </li>
55 <?php
56 }
57
58 /**
59 * Get field options setting
60 *
61 * @return array
62 */
63 public function get_options_settings() {
64 $default_options = $this->get_default_option_settings( true, array( 'width' ) );
65 $dropdown_options = array(
66 $this->get_default_option_dropdown_settings(),
67
68 array(
69 'name' => 'inline',
70 'title' => __( 'Show in inline list', 'weforms' ),
71 'type' => 'radio',
72 'options' => array(
73 'yes' => __( 'Yes', 'weforms' ),
74 'no' => __( 'No', 'weforms' ),
75 ),
76 'default' => 'no',
77 'inline' => true,
78 'section' => 'advanced',
79 'priority' => 23,
80 'help_text' => __( 'Show this option in an inline list', 'weforms' ),
81 )
82 );
83
84 $dropdown_options = apply_filters( 'weforms_radio_field_option_settings', $dropdown_options );
85
86 return array_merge( $default_options, $dropdown_options );
87 }
88
89 /**
90 * Get the field props
91 *
92 * @return array
93 */
94 public function get_field_props() {
95 $defaults = $this->default_attributes();
96 $props = array(
97 'selected' => '',
98 'inline' => 'no',
99 'options' => array( 'Option' => __( 'Option', 'weforms' ) ),
100 );
101
102 $props = apply_filters( 'weforms_radio_field_props', $props );
103
104 return array_merge( $defaults, $props );
105 }
106
107 /**
108 * Prepare entry
109 *
110 * @param $field
111 *
112 * @return mixed
113 */
114 public function prepare_entry( $field ) {
115 $val = $_POST[$field['name']];
116 return isset( $field['options'][$val] ) ? $field['options'][$val] : '';
117 }
118 }