PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.2.8
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.2.8
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.2.8, at includes/fields/class-field-radio.php

112 lines 3.5 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 <div class="wpuf-fields" data-required="<?php echo $field_settings['required'] ?>" data-type="radio">
29
30 <?php
31 if ( $field_settings['options'] && count( $field_settings['options'] ) > 0 ) {
32 foreach ($field_settings['options'] as $value => $option) {
33 ?>
34
35 <label <?php echo $field_settings['inline'] == 'yes' ? 'class="wpuf-radio-inline"' : 'class="wpuf-radio-block"'; ?>>
36 <input
37 name="<?php echo $field_settings['name']; ?>"
38 class="<?php echo 'wpuf_'.$field_settings['name']. '_'. $form_id; ?>"
39 type="radio"
40 value="<?php echo esc_attr( $value ); ?>"<?php checked( $selected, $value ); ?>
41 />
42 <?php echo $option; ?>
43 </label>
44 <?php
45 }
46 }
47 ?>
48
49 <?php $this->help_text( $field_settings ); ?>
50
51 </div>
52 </li>
53 <?php
54 }
55
56 /**
57 * Get field options setting
58 *
59 * @return array
60 */
61 public function get_options_settings() {
62 $default_options = $this->get_default_option_settings( true, array( 'width' ) );
63 $dropdown_options = array(
64 $this->get_default_option_dropdown_settings(),
65
66 array(
67 'name' => 'inline',
68 'title' => __( 'Show in inline list', 'weforms' ),
69 'type' => 'radio',
70 'options' => array(
71 'yes' => __( 'Yes', 'weforms' ),
72 'no' => __( 'No', 'weforms' ),
73 ),
74 'default' => 'no',
75 'inline' => true,
76 'section' => 'advanced',
77 'priority' => 23,
78 'help_text' => __( 'Show this option in an inline list', 'weforms' ),
79 )
80 );
81
82 return array_merge( $default_options, $dropdown_options );
83 }
84
85 /**
86 * Get the field props
87 *
88 * @return array
89 */
90 public function get_field_props() {
91 $defaults = $this->default_attributes();
92 $props = array(
93 'selected' => '',
94 'inline' => 'no',
95 'options' => array( 'Option' => __( 'Option', 'weforms' ) ),
96 );
97
98 return array_merge( $defaults, $props );
99 }
100
101 /**
102 * Prepare entry
103 *
104 * @param $field
105 *
106 * @return mixed
107 */
108 public function prepare_entry( $field ) {
109 $val = $_POST[$field['name']];
110 return isset( $field['options'][$val] ) ? $field['options'][$val] : '';
111 }
112 }