echo FrmFieldsHelper::dropdown_categories(array('name' => $field_name, 'field' => $field)); } else { ?> <select name="<?php echo esc_attr($field_name) . (FrmField::is_option_true($field, 'multiple') ? '[]' : ''); ?> " <?php echo FrmField::is_option_true($field, 'size') ? 'class="auto_width"' : ''; echo FrmField::is_option_true($field, 'multiple') ? ' multiple="multiple"' : ''; ?> > <?php foreach ($field['options'] as $opt_key => $opt) { $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); $selected = $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val(array('opt_key', 'field')) ? ' selected="selected"' : ''; ?> <option value="<?php echo esc_attr($field_val); ?> "<?php echo $selected; ?> ><?php echo esc_html($opt); ?> </option> <?php } ?> </select>
/** * Get value that belongs in "Other" text box * * @since 2.0 * * @param string $opt_key * @param array $field * @return string $other_val */ public static function get_other_val($opt_key, $field, $parent = false, $pointer = false) { _deprecated_function(__FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val'); return FrmFieldsHelper::get_other_val(compact('opt_key', 'field', 'parent', 'pointer')); }
<?php if (!is_array($field['options'])) { return; } foreach ($field['options'] as $opt_key => $opt) { $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); // Get string for Other text field, if needed $other_val = FrmFieldsHelper::get_other_val(compact('opt_key', 'field')); $checked = $other_val || isset($field['value']) && (!is_array($field['value']) && $field['value'] == $field_val || is_array($field['value']) && in_array($field_val, $field['value'])) ? ' checked="checked"' : ''; if (FrmFieldsHelper::is_other_opt($opt_key)) { include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php'; } else { include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php'; } unset($checked, $other_val); }