ip' => $tooltip, ], false ); // Field option choices inputs $option_choices = sprintf(''; // Field option row (markup) including label and input. $output = $this->field_element( 'row', $field, [ 'slug' => 'choices', 'content' => $option_label . $option_choices, ] ); } /** * Field preview inside the builder. * * @since 1.0.0 * @param array $field */ public function field_preview($field) { $values = ! empty($field['choices']) ? $field['choices'] : $this->defaults; // Field checkbox elements echo ''; // Dynamic population is enabled and contains more than 20 items if (isset($total) && $total > 20) { echo '
'; printf(__('Showing the first 20 choices.
All %d choices will be displayed when viewing the form.', 'wpforms'), absint($total)); echo '
'; } // Description $this->field_preview_option('description', $field); } /** * Field display on the form front-end. * * @since 1.0.0 * @param null $field (deprecated) * @param array $form_data */ public function field_display($field, $field_atts, $form_data) { // Setup some defaults because WPForms broke their integration in v1.8.1.1 $field_atts = array_merge([ 'input_class' => [], 'input_id' => [], ], is_array($field_atts) ? $field_atts : []); // Setup and sanitize the necessary data $field_required = ! empty($field['required']) ? ' required' : ''; $field_class = implode(' ', array_map('sanitize_html_class', (array) $field_atts['input_class'])); $field_id = implode(' ', array_map('sanitize_html_class', (array) $field_atts['input_id'])); $form_id = $form_data['id']; $choices = (array) $field['choices']; // List printf(''; } /** * Formats and sanitizes field. * * @since 1.0.2 * @param int $field_id * @param array $field_submit * @param array $form_data */ public function format($field_id, $field_submit, $form_data) { $field = $form_data['fields'][ $field_id ]; $choice = array_pop($field['choices']); $name = sanitize_text_field($choice['label']); $data = [ 'name' => $name, 'value' => empty($field_submit) ? __('No', 'mailchimp-for-wp') : __('Yes', 'mailchimp-for-wp'), 'value_raw' => $field_submit, 'id' => absint($field_id), 'type' => $this->type, ]; wpforms()->process->fields[ $field_id ] = $data; } }