本文整理汇总了PHP中GFCommon::get_select_choices方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::get_select_choices方法的具体用法?PHP GFCommon::get_select_choices怎么用?PHP GFCommon::get_select_choices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::get_select_choices方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_users_as_choices
public function get_users_as_choices($value)
{
$form_id = $this->formId;
$args = apply_filters('gravityflow_get_users_args_user_field', array('orderby' => 'display_name'), $form_id, $this);
$accounts = get_users($args);
$account_choices = array();
foreach ($accounts as $account) {
$account_choices[] = array('value' => $account->ID, 'text' => $account->display_name);
}
$account_choices = apply_filters('gravityflow_user_field', $account_choices, $form_id, $this);
$this->choices = $account_choices;
$choices = GFCommon::get_select_choices($this, $value);
return $choices;
}
示例2: get_roles_as_choices
public function get_roles_as_choices($value)
{
global $wp_roles;
$form_id = $this->formId;
$editable_roles = $wp_roles->roles;
$role_choices = array();
foreach ($editable_roles as $role => $details) {
$name = translate_user_role($details['name']);
$role_choices[] = array('value' => $role, 'text' => $name);
}
$role_choices = apply_filters('gravityflow_role_field', $role_choices, $form_id, $this);
$this->choices = $role_choices;
$choices = GFCommon::get_select_choices($this, $value);
return $choices;
}
示例3: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$logic_event = $this->get_conditional_logic_event('change');
$size = $this->size;
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$css_class = trim(esc_attr($class) . ' gfield_select');
$tabindex = $this->get_tabindex();
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, GFCommon::get_select_choices($this, $value));
}
示例4: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$logic_event = $this->get_conditional_logic_event('keyup');
$size = $this->size;
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$css_class = trim(esc_attr($class) . ' gfield_select');
$tabindex = $this->get_tabindex();
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$placeholder = $this->enableEnhancedUI ? "data-placeholder='" . esc_attr(apply_filters("gform_multiselect_placeholder_{$form_id}", apply_filters('gform_multiselect_placeholder', __('Click to select...', 'gravityforms'), $form_id), $form_id)) . "'" : '';
$size = $this->multiSelectSize;
if (empty($size)) {
$size = 7;
}
return sprintf("<div class='ginput_container'><select multiple='multiple' {$placeholder} size='{$size}' name='input_%d[]' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, GFCommon::get_select_choices($this, $value));
}
示例5: deprecated_envoy_field_field_input
function deprecated_envoy_field_field_input($input, $field, $value, $lead_id, $form_id)
{
if ($field["type"] == "envoyrecharge") {
$max_chars = "";
if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
$max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
}
$input_name = $form_id . '_' . $field["id"];
$tabindex = GFCommon::get_tabindex();
$css = isset($field['cssClass']) ? $field['cssClass'] : "";
//add a variable to disable a select field if admin dashboard is opened
if (IS_ADMIN) {
$disabled = 'disabled';
} else {
$disabled = '';
}
$amount = '';
$frequency = '';
$recurring = '';
if (is_array($value)) {
$amount = esc_attr(rgget($field["id"] . ".1", $value));
$frequency = rgget($field["id"] . ".2", $value);
$recurring = rgget('input_' . $field['id'] . '.5') == "recurring" ? "checked='checked'" : "";
}
$recur_label = empty($field['field_envoyrecharge_recur_label']) ? 'Yes, I want to make a recurring donation' : $field['field_envoyrecharge_recur_label'];
$recur_hidden = !empty($field['field_envoyrecharge_recurring_disabled']) ? ' style="display: none;"' : '';
$html = "<div class='ginput_container'>" . "\n";
$html .= '<input name="input_' . $field['id'] . '.1" id="input_' . $input_name . '_1" class="gform_ech ginput_amount ' . $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'] . '" type="text" ' . $disabled . ' value="' . $amount . '">';
$html .= '<div class="gform_envoyrecharge_recurring envoyrecharge_recur_setting"' . $recur_hidden . '><input name="input_' . $field['id'] . '.5" id="ginput_envoyrecharge_recurring_' . $field['id'] . '" type="checkbox" ' . $disabled . ' value="recurring" ' . $recurring . ' onclick="EnvoyToggleRecurring(jQuery(this));">
<label class="ginput_envoyrecharge_label" id="ginput_envoyrecharge_label_' . $field['id'] . '" for="ginput_envoyrecharge_recurring_' . $field['id'] . '">' . $recur_label . '</label></div>';
$html .= "\n <select {$disabled} data-checkbox='ginput_envoyrecharge_recurring_" . $field['id'] . "' name='input_" . $field['id'] . ".2' id='input_" . $input_name . "_2' class='select envoyrecharge_recur_setting envoyrecharge_recur_frequency gform_ech " . $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'] . "'{$recur_hidden}>" . GFCommon::get_select_choices($field, $value) . "</select>";
$html .= "</div>";
return $html;
}
return $input;
}
示例6: get_choices
public function get_choices($value)
{
return GFCommon::get_select_choices($this, $value);
}
示例7: get_assignees_as_choices
public function get_assignees_as_choices($value, $include_users = true, $include_roles = true, $include_fields = true)
{
global $wp_roles;
$form_id = $this->formId;
$account_choices = $role_choices = $fields_choices = array();
$optgroups = array();
if ($include_users) {
$args = apply_filters('gravityflow_get_users_args_assignee_field', array('number' => 1000, 'orderby' => 'display_name'), $form_id, $this);
$accounts = get_users($args);
$account_choices = array();
foreach ($accounts as $account) {
$account_choices[] = array('value' => 'user_id|' . $account->ID, 'text' => $account->display_name);
}
$account_choices = apply_filters('gravityflow_assignee_field_users', $account_choices, $form_id, $this);
$optgroups = array();
if (!empty($account_choices)) {
$users_opt_group = new GF_Field();
$users_opt_group->choices = $account_choices;
$optgroups[] = array('label' => __('Users', 'gravityflow'), 'choices' => GFCommon::get_select_choices($users_opt_group, $value));
}
}
if ($include_roles) {
$editable_roles = array_reverse($wp_roles->roles);
$role_choices = array();
foreach ($editable_roles as $role => $details) {
$name = translate_user_role($details['name']);
$role_choices[] = array('value' => 'role|' . $role, 'text' => $name);
}
$role_choices = apply_filters('gravityflow_assignee_field_roles', $role_choices, $form_id, $this);
if (!empty($role_choices)) {
$roles_opt_group = new GF_Field();
$roles_opt_group->choices = $role_choices;
$optgroups[] = array('label' => __('Roles', 'gravityflow'), 'key' => 'roles', 'choices' => GFCommon::get_select_choices($roles_opt_group, $value));
}
}
if ($include_fields) {
$form_id = $this->formId;
$form = GFAPI::get_form($form_id);
if (rgar($form, 'requireLogin')) {
$fields_choices = array(array('text' => __('User (Created by)', 'gravityflow'), 'value' => 'entry|created_by'));
$fields_choices = apply_filters('gravityflow_assignee_field_fields', $fields_choices, $form_id, $this);
if (!empty($fields_choices)) {
$fields_opt_group = new GF_Field();
$fields_opt_group->choices = $fields_choices;
$optgroups[] = array('label' => __('Fields', 'gravityflow'), 'choices' => GFCommon::get_select_choices($fields_opt_group, $value));
}
}
}
$html = '';
if (!empty($this->placeholder)) {
$selected = empty($value) ? "selected='selected'" : '';
$html = sprintf("<option value='' %s class='gf_placeholder'>%s</option>", $selected, esc_html($this->placeholder));
}
foreach ($optgroups as $optgroup) {
$html .= sprintf('<optgroup label="%s">%s</optgroup>', $optgroup['label'], $optgroup['choices']);
}
return $html;
}