本文整理汇总了PHP中RGFormsModel::is_html5_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::is_html5_enabled方法的具体用法?PHP RGFormsModel::is_html5_enabled怎么用?PHP RGFormsModel::is_html5_enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::is_html5_enabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_field_input
/**
* Returns the field input.
*
* @param array $form
* @param string $value
* @param null|array $entry
*
* @return string
*/
public function get_field_input($form, $value = '', $entry = null)
{
if (is_array($value)) {
$value = '';
}
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$instruction_div = '';
if ($this->failed_validation) {
$phone_format = $this->get_phone_format();
if (rgar($phone_format, 'instruction')) {
$instruction_div = sprintf("<div class='instruction validation_message'>%s %s</div>", esc_html__('Phone format:', 'gravityforms'), $phone_format['instruction']);
}
}
$html_input_type = RGFormsModel::is_html5_enabled() ? 'tel' : 'text';
$logic_event = $this->get_conditional_logic_event('keyup');
$placeholder_attribute = $this->get_field_placeholder_attribute();
$required_attribute = $this->isRequired ? 'aria-required="true"' : '';
$invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
$tabindex = $this->get_tabindex();
return sprintf("<div class='ginput_container ginput_container_phone'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} {$logic_event} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
}
示例2: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
if (is_array($value)) {
$value = array_values($value);
}
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $this->emailConfirmEnabled ? '' : $size . $class_suffix;
//Size only applies when confirmation is disabled
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
$html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text';
$enter_email_field_input = GFFormsModel::get_input($this, $this->id . '');
$confirm_field_input = GFFormsModel::get_input($this, $this->id . '.2');
$enter_email_label = rgar($enter_email_field_input, 'customLabel') != '' ? $enter_email_field_input['customLabel'] : __('Enter Email', 'gravityforms');
$enter_email_label = apply_filters("gform_email_{$form_id}", apply_filters('gform_email', $enter_email_label, $form_id), $form_id);
$confirm_email_label = rgar($confirm_field_input, 'customLabel') != '' ? $confirm_field_input['customLabel'] : __('Confirm Email', 'gravityforms');
$confirm_email_label = apply_filters("gform_email_confirm_{$form_id}", apply_filters('gform_email_confirm', $confirm_email_label, $form_id), $form_id);
$single_placeholder_attribute = $this->get_field_placeholder_attribute();
$enter_email_placeholder_attribute = $this->get_input_placeholder_attribute($enter_email_field_input);
$confirm_email_placeholder_attribute = $this->get_input_placeholder_attribute($confirm_field_input);
if ($is_form_editor) {
$single_style = $this->emailConfirmEnabled ? "style='display:none;'" : '';
$confirm_style = $this->emailConfirmEnabled ? '' : "style='display:none;'";
if ($is_sub_label_above) {
return "<div class='ginput_container ginput_single_email' {$single_style}>\n <input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute} />\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
} else {
return "<div class='ginput_container ginput_single_email' {$single_style}>\n <input class='{$class}' name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute}/>\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
}
} else {
$logic_event = $this->get_conditional_logic_event('keyup');
if ($this->emailConfirmEnabled && !$is_entry_detail) {
$first_tabindex = $this->get_tabindex();
$last_tabindex = $this->get_tabindex();
$email_value = is_array($value) ? esc_attr($value[0]) : $value;
$confirmation_value = is_array($value) ? esc_attr($value[1]) : rgpost('input_' . $this->id . '_2');
$confirmation_disabled = $is_entry_detail ? "disabled='disabled'" : $disabled_text;
if ($is_sub_label_above) {
return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <label for='{$field_id}'>" . $enter_email_label . "</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
} else {
return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
}
} else {
$tabindex = $this->get_tabindex();
$value = esc_attr($value);
$class = esc_attr($class);
return "<div class='ginput_container'>\n <input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$disabled_text} {$single_placeholder_attribute}/>\n </div>";
}
}
}
示例3: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = rgar($this, 'subLabelPlacement');
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$hour = $minute = $am_selected = $pm_selected = '';
if (!is_array($value) && !empty($value)) {
preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
$hour = esc_attr($matches[1]);
$minute = esc_attr($matches[2]);
$the_rest = strtolower(rgar($matches, 3));
$am_selected = strpos($the_rest, 'am') > -1 ? "selected='selected'" : '';
$pm_selected = strpos($the_rest, 'pm') > -1 ? "selected='selected'" : '';
} else {
if (is_array($value)) {
$value = array_values($value);
$hour = esc_attr($value[0]);
$minute = esc_attr($value[1]);
$am_selected = strtolower(rgar($value, 2)) == 'am' ? "selected='selected'" : '';
$pm_selected = strtolower(rgar($value, 2)) == 'pm' ? "selected='selected'" : '';
}
}
$hour_input = GFFormsModel::get_input($this, $this->id . '.1');
$minute_input = GFFormsModel::get_input($this, $this->id . '.2');
$hour_placeholder_attribute = $this->get_input_placeholder_attribute($hour_input);
$minute_placeholder_attribute = $this->get_input_placeholder_attribute($minute_input);
$hour_tabindex = $this->get_tabindex();
$minute_tabindex = $this->get_tabindex();
$ampm_tabindex = $this->get_tabindex();
$is_html5 = RGFormsModel::is_html5_enabled();
$input_type = $is_html5 ? 'number' : 'text';
$max_hour = $this->timeFormat == '24' ? 23 : 12;
$hour_html5_attributes = $is_html5 ? "min='0' max='{$max_hour}' step='1'" : '';
$minute_html5_attributes = $is_html5 ? "min='0' max='59' step='1'" : '';
$ampm_field_style = $is_form_editor && $this->timeFormat == '24' ? "style='display:none;'" : '';
if ($is_form_editor || $this->timeFormat != '24') {
$am_text = __('AM', 'gravityforms');
$pm_text = __('PM', 'gravityforms');
$ampm_field = $is_sub_label_above ? "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}>\n <label for='{$field_id}_3'> </label>\n <select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}>\n <option value='am' {$am_selected}>{$am_text}</option>\n <option value='pm' {$pm_selected}>{$pm_text}</option>\n </select>\n </div>" : "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}>\n <select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}>\n <option value='am' {$am_selected}>{$am_text}</option>\n <option value='pm' {$pm_selected}>{$pm_text}</option>\n </select>\n </div>";
} else {
$ampm_field = '';
}
$hour_label = rgar($hour_input, 'customLabel') != '' ? $hour_input['customLabel'] : __('HH', 'gravityforms');
$minute_label = rgar($minute_input, 'customLabel') != '' ? $minute_input['customLabel'] : _x('MM', 'Abbreviation: Minutes', 'gravityforms');
if ($is_sub_label_above) {
return "<div class='clear-multi'>\n <div class='gfield_time_hour ginput_container' id='{$field_id}'>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$hour_label}</label>\n <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$hour}' {$hour_tabindex} {$hour_html5_attributes} {$disabled_text} {$hour_placeholder_attribute}/> <i>:</i>\n </div>\n <div class='gfield_time_minute ginput_container'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$minute_label}</label>\n <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$minute}' {$minute_tabindex} {$minute_html5_attributes} {$disabled_text} {$minute_placeholder_attribute}/>\n </div>\n {$ampm_field}\n </div>";
} else {
return "<div class='clear-multi'>\n <div class='gfield_time_hour ginput_container' id='{$field_id}'>\n <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$hour}' {$hour_tabindex} {$hour_html5_attributes} {$disabled_text} {$hour_placeholder_attribute}/> <i>:</i>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$hour_label}</label>\n </div>\n <div class='gfield_time_minute ginput_container'>\n <input type='{$input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$minute}' {$minute_tabindex} {$minute_html5_attributes} {$disabled_text} {$minute_placeholder_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$minute_label}</label>\n </div>\n {$ampm_field}\n </div>";
}
}
示例4: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$instruction = $this->phoneFormat == 'standard' ? esc_html__('Phone format:', 'gravityforms') . ' (###) ###-####' : '';
$instruction_div = $this->failed_validation && !empty($instruction) ? "<div class='instruction validation_message'>{$instruction}</div>" : '';
$html_input_type = RGFormsModel::is_html5_enabled() ? 'tel' : 'text';
$logic_event = $this->get_conditional_logic_event('keyup');
$placeholder_attribute = $this->get_field_placeholder_attribute();
$tabindex = $this->get_tabindex();
return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} {$logic_event} {$placeholder_attribute} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
}
示例5: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$is_html5 = RGFormsModel::is_html5_enabled();
$html_input_type = $is_html5 ? 'url' : 'text';
$max_length = is_numeric($this->maxLength) ? "maxlength='{$this->maxLength}'" : '';
$logic_event = $this->get_conditional_logic_event('keyup');
$placeholder_attribute = $this->get_field_placeholder_attribute();
$tabindex = $this->get_tabindex();
$value = esc_attr($value);
$class = esc_attr($class);
return "<div class='ginput_container'>\n <input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$max_length} {$tabindex} {$logic_event} {$disabled_text} {$placeholder_attribute}/>\n </div>";
}
示例6: replace_save_variables
public static function replace_save_variables($text, $form, $resume_token, $email = null)
{
$resume_token = sanitize_key($resume_token);
$form_id = intval($form['id']);
$resume_url = apply_filters('gform_save_and_continue_resume_url', add_query_arg(array('gf_token' => $resume_token), GFFormsModel::get_current_page_url()), $form, $resume_token, $email);
$resume_url = esc_url($resume_url);
$resume_link = "<a href=\"{$resume_url}\" class='resume_form_link'>{$resume_url}</a>";
$text = str_replace('{save_link}', $resume_link, $text);
$text = str_replace('{save_token}', $resume_token, $text);
$text = str_replace('{save_url}', $resume_url, $text);
$email_esc = esc_attr($email);
$text = str_replace('{save_email}', $email_esc, $text);
$resume_submit_button_text = esc_html__('Send Email', 'gravityforms');
$resume_email_validation_message = esc_html__('Please enter a valid email address.', 'gravityforms');
// The {save_email_input} accepts shortcode-style options button_text and validation_message. E.g.,
// {save_email_input: button_text="Send the link to my email address" validation_message="The link couldn't be sent because the email address is not valid."}
preg_match_all('/\\{save_email_input:(.*?)\\}/', $text, $matches, PREG_SET_ORDER);
if (is_array($matches) && isset($matches[0]) && isset($matches[0][1])) {
$options_string = isset($matches[0][1]) ? $matches[0][1] : '';
$options = shortcode_parse_atts($options_string);
if (isset($options['button_text'])) {
$resume_submit_button_text = $options['button_text'];
}
if (isset($options['validation_message'])) {
$resume_email_validation_message = $options['validation_message'];
}
$full_tag = $matches[0][0];
$text = str_replace($full_tag, '{save_email_input}', $text);
}
$action = esc_url(remove_query_arg('gf_token'));
$ajax = isset($_POST['gform_ajax']);
$has_pages = self::has_pages($form);
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
if ($use_anchor !== false) {
$action .= "#gf_{$form_id}";
}
$html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text';
$resume_token = esc_attr($resume_token);
$validation_message = !is_null($email) && !GFCommon::is_valid_email($email) ? sprintf('<div class="validation_message">%s</div>', $resume_email_validation_message) : '';
$nonce_input = '';
if (rgar($form, 'requireLogin')) {
$nonce_input = wp_nonce_field('gform_send_resume_link', '_gform_send_resume_link_nonce', true, false);
}
$target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : '';
$ajax_fields = '';
if ($ajax) {
$ajax_fields = "<input type='hidden' name='gform_ajax' value='" . esc_attr("form_id={$form_id}&title=1&description=1&tabindex=1") . "' />";
$ajax_fields .= "<input type='hidden' name='gform_field_values' value='' />";
}
$resume_form = "<div class='form_saved_message_emailform'>\n\t\t\t\t\t\t\t<form action='{$action}' method='POST' id='gform_{$form_id}' {$target}>\n\t\t\t\t\t\t\t\t{$ajax_fields}\n\t\t\t\t\t\t\t\t<input type='{$html_input_type}' name='gform_resume_email' value='{$email_esc}'/>\n\t\t\t\t\t\t\t\t<input type='hidden' name='gform_resume_token' value='{$resume_token}' />\n\t\t\t\t\t\t\t\t<input type='hidden' name='gform_send_resume_link' value='{$form_id}' />\n\t <input type='submit' name='gform_send_resume_link_button' id='gform_send_resume_link_button_{$form_id}' value='{$resume_submit_button_text}' />\n\t {$validation_message}\n\t {$nonce_input}\n\t\t\t\t\t\t\t</form>\n\t </div>";
$text = str_replace('{save_email_input}', $resume_form, $text);
return $text;
}
示例7: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$picker_value = '';
if (is_array($value)) {
// GFCommon::parse_date() takes a numeric array.
$value = array_values($value);
} else {
$picker_value = $value;
}
$format = empty($this->dateFormat) ? 'mdy' : esc_attr($this->dateFormat);
$date_info = GFCommon::parse_date($value, $format);
$day_value = esc_attr(rgget('day', $date_info));
$month_value = esc_attr(rgget('month', $date_info));
$year_value = esc_attr(rgget('year', $date_info));
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = rgar($this, 'subLabelPlacement');
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
$month_input = GFFormsModel::get_input($this, $this->id . '.1');
$day_input = GFFormsModel::get_input($this, $this->id . '.2');
$year_input = GFFormsModel::get_input($this, $this->id . '.3');
$month_sub_label = rgar($month_input, 'customLabel') != '' ? $month_input['customLabel'] : esc_html(_x('MM', 'Abbreviation: Month', 'gravityforms'));
$day_sub_label = rgar($day_input, 'customLabel') != '' ? $day_input['customLabel'] : esc_html__('DD', 'gravityforms');
$year_sub_label = rgar($year_input, 'customLabel') != '' ? $year_input['customLabel'] : esc_html__('YYYY', 'gravityforms');
$month_placeholder_attribute = GFCommon::get_input_placeholder_attribute($month_input);
$day_placeholder_attribute = GFCommon::get_input_placeholder_attribute($day_input);
$year_placeholder_attribute = GFCommon::get_input_placeholder_attribute($year_input);
$month_placeholder_value = GFCommon::get_input_placeholder_value($month_input);
$day_placeholder_value = GFCommon::get_input_placeholder_value($day_input);
$year_placeholder_value = GFCommon::get_input_placeholder_value($year_input);
$date_picker_placeholder = $this->get_field_placeholder_attribute();
$is_html5 = RGFormsModel::is_html5_enabled();
$date_input_type = $is_html5 ? 'number' : 'text';
$month_html5_attributes = $is_html5 ? "min='1' max='12' step='1'" : '';
$day_html5_attributes = $is_html5 ? "min='1' max='31' step='1'" : '';
$year_min = apply_filters('gform_date_min_year', '1920', $form, $this);
$year_max = apply_filters('gform_date_max_year', date('Y') + 1, $form, $this);
$year_min_attribute = $is_html5 && is_numeric($year_min) ? "min='{$year_min}'" : '';
$year_max_attribute = $is_html5 && is_numeric($year_max) ? "max='{$year_max}'" : '';
$year_step_attribute = $is_html5 ? "step='1'" : '';
$field_position = substr($format, 0, 3);
if ($is_form_editor) {
$datepicker_display = in_array($this->dateType, array('datefield', 'datedropdown')) ? 'none' : 'inline';
$datefield_display = $this->dateType == 'datefield' ? 'inline' : 'none';
$dropdown_display = $this->dateType == 'datedropdown' ? 'inline' : 'none';
$icon_display = $this->calendarIconType == 'calendar' ? 'inline' : 'none';
if ($is_sub_label_above) {
$month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n <input id='{$field_id}_1' name='ginput_month' type='text' {$month_placeholder_attribute} {$disabled_text} value='{$month_value}'/>\n </div>";
$day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n <input id='{$field_id}_2' name='ginput_day' type='text' {$day_placeholder_attribute} {$disabled_text} value='{$day_value}'/>\n </div>";
$year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'>\n <label {$sub_label_class_attribute}>{$year_sub_label}</label>\n <input id='{$field_id}_3' type='text' name='text' {$year_placeholder_attribute} {$disabled_text} value='{$year_value}'/>\n </div>";
} else {
$month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'>\n <input id='{$field_id}_1' name='ginput_month' type='text' {$month_placeholder_attribute} {$disabled_text} value='{$month_value}'/>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n </div>";
$day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'>\n <input id='{$field_id}_2' name='ginput_day' type='text' {$day_placeholder_attribute} {$disabled_text} value='{$day_value}'/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n </div>";
$year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'>\n <input type='text' id='{$field_id}_3' name='ginput_year' {$year_placeholder_attribute} {$disabled_text} value='{$year_value}'/>\n <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n </div>";
}
$month_dropdown = "<div class='gfield_date_dropdown_month ginput_date_dropdown' id='gfield_dropdown_date_month' style='display:{$dropdown_display}'>" . $this->get_month_dropdown('', "{$field_id}_1", rgar($date_info, 'month'), '', $disabled_text, $month_placeholder_value) . '</div>';
$day_dropdown = "<div class='gfield_date_dropdown_day ginput_date_dropdown' id='gfield_dropdown_date_day' style='display:{$dropdown_display}'>" . $this->get_day_dropdown('', "{$field_id}_2", rgar($date_info, 'day'), '', $disabled_text, $day_placeholder_value) . '</div>';
$year_dropdown = "<div class='gfield_date_dropdown_year ginput_date_dropdown' id='gfield_dropdown_date_year' style='display:{$dropdown_display}'>" . $this->get_year_dropdown('', "{$field_id}_3", rgar($date_info, 'year'), '', $disabled_text, $year_placeholder_value, $form) . '</div>';
$field_string = "<div class='ginput_container ginput_container_date' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' {$date_picker_placeholder} {$disabled_text} value = '{$picker_value}'/><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
switch ($field_position) {
case 'dmy':
$date_inputs = $day_field . $month_field . $year_field . $day_dropdown . $month_dropdown . $year_dropdown;
break;
case 'ymd':
$date_inputs = $year_field . $month_field . $day_field . $year_dropdown . $month_dropdown . $day_dropdown;
break;
default:
$date_inputs = $month_field . $day_field . $year_field . $month_dropdown . $day_dropdown . $year_dropdown;
break;
}
$field_string .= "<div id='{$field_id}' class='ginput_container ginput_container_date'>{$date_inputs}</div>";
return $field_string;
} else {
$date_type = $this->dateType;
if (in_array($date_type, array('datefield', 'datedropdown'))) {
switch ($field_position) {
case 'dmy':
$tabindex = $this->get_tabindex();
if ($date_type == 'datedropdown') {
$field_str = "<div class='clear-multi'><div class='gfield_date_dropdown_day ginput_container ginput_container_date' id='{$field_id}_2_container'>" . $this->get_day_dropdown("input_{$id}[]", "{$field_id}_2", rgar($date_info, 'day'), $tabindex, $disabled_text, $day_placeholder_value) . '</div>';
$tabindex = $this->get_tabindex();
$field_str .= "<div class='gfield_date_dropdown_month ginput_container ginput_container_date' id='{$field_id}_1_container'>" . $this->get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, 'month'), $tabindex, $disabled_text, $month_placeholder_value) . '</div>';
$tabindex = $this->get_tabindex();
$field_str .= "<div class='gfield_date_dropdown_year ginput_container ginput_container_date' id='{$field_id}_3_container'>" . $this->get_year_dropdown("input_{$id}[]", "{$field_id}_3", rgar($date_info, 'year'), $tabindex, $disabled_text, $year_placeholder_value, $form) . '</div></div>';
} else {
$field_str = $is_sub_label_above ? "<div class='clear-multi'>\n <div class='gfield_date_day ginput_container ginput_container_date' id='{$field_id}_2_container'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$day_value}' {$tabindex} {$disabled_text} {$day_placeholder_attribute} {$day_html5_attributes}/>\n </div>" : "<div class='clear-multi'>\n <div class='gfield_date_day ginput_container ginput_container_date' id='{$field_id}_2_container'>\n <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$day_value}' {$tabindex} {$disabled_text} {$day_placeholder_attribute} {$day_html5_attributes}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n </div>";
$tabindex = $this->get_tabindex();
$field_str .= $is_sub_label_above ? "<div class='gfield_date_month ginput_container ginput_container_date' id='{$field_id}_1_container'>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$month_value}' {$tabindex} {$disabled_text} {$month_placeholder_attribute} {$month_html5_attributes}/>\n </div>" : "<div class='gfield_date_month ginput_container ginput_container_date' id='{$field_id}_1_container'>\n <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$month_value}' {$tabindex} {$disabled_text} {$month_placeholder_attribute} {$month_html5_attributes}/>\n <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n </div>";
$tabindex = $this->get_tabindex();
$field_str .= $is_sub_label_above ? "<div class='gfield_date_year ginput_container ginput_container_date' id='{$field_id}_3_container'>\n <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n <input type='{$date_input_type}' maxlength='4' name='input_{$id}[]' id='{$field_id}_3' value='{$year_value}' {$tabindex} {$disabled_text} {$year_placeholder_attribute} {$year_min_attribute} {$year_max_attribute} {$year_step_attribute}/>\n </div>\n </div>" : "<div class='gfield_date_year ginput_container ginput_container_date' id='{$field_id}_3_container'>\n <input type='{$date_input_type}' maxlength='4' name='input_{$id}[]' id='{$field_id}_3' value='{$year_value}' {$tabindex} {$disabled_text} {$year_placeholder_attribute} {$year_min_attribute} {$year_max_attribute} {$year_step_attribute}/>\n <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n </div>\n </div>";
}
//.........这里部分代码省略.........
示例8: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
$card_number = '';
$card_name = '';
$expiration_month = '';
$expiration_year = '';
$security_code = '';
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
if (is_array($value)) {
$card_number = esc_attr(rgget($this->id . '.1', $value));
$card_name = esc_attr(rgget($this->id . '.5', $value));
$expiration_date = rgget($this->id . '.2', $value);
if (!is_array($expiration_date) && !empty($expiration_date)) {
$expiration_date = explode('/', $expiration_date);
}
if (is_array($expiration_date) && count($expiration_date) == 2) {
$expiration_month = $expiration_date[0];
$expiration_year = $expiration_date[1];
}
$security_code = esc_attr(rgget($this->id . '.3', $value));
}
$action = !($is_entry_detail || $is_form_editor) ? "gformMatchCard(\"{$field_id}_1\");" : '';
$onchange = "onchange='{$action}'";
$onkeyup = "onkeyup='{$action}'";
$card_icons = '';
$cards = GFCommon::get_card_types();
$card_style = $this->creditCardStyle ? $this->creditCardStyle : 'style1';
foreach ($cards as $card) {
$style = '';
if ($this->is_card_supported($card['slug'])) {
$print_card = true;
} elseif ($is_form_editor || $is_entry_detail) {
$print_card = true;
$style = "style='display:none;'";
} else {
$print_card = false;
}
if ($print_card) {
$card_icons .= "<div class='gform_card_icon gform_card_icon_{$card['slug']}' {$style}>{$card['name']}</div>";
}
}
$payment_methods = apply_filters('gform_payment_methods', array(), $this, $form_id);
$payment_options = '';
if (is_array($payment_methods)) {
foreach ($payment_methods as $payment_method) {
$checked = rgpost('gform_payment_method') == $payment_method['key'] ? "checked='checked'" : '';
$payment_options .= "<div class='gform_payment_option gform_payment_{$payment_method['key']}'><input type='radio' name='gform_payment_method' value='{$payment_method['key']}' id='gform_payment_method_{$payment_method['key']}' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/> {$payment_method['label']}</div>";
}
}
$checked = rgpost('gform_payment_method') == 'creditcard' || rgempty('gform_payment_method') ? "checked='checked'" : '';
$card_radio_button = empty($payment_options) ? '' : "<input type='radio' name='gform_payment_method' id='gform_payment_method_creditcard' value='creditcard' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/>";
$card_icons = "{$payment_options}<div class='gform_card_icon_container gform_card_icon_{$card_style}'>{$card_radio_button}{$card_icons}</div>";
//card number fields
$tabindex = $this->get_tabindex();
$card_number_field_input = GFFormsModel::get_input($this, $this->id . '.1');
$html5_output = !is_admin() && GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
$card_number_label = rgar($card_number_field_input, 'customLabel') != '' ? $card_number_field_input['customLabel'] : esc_html__('Card Number', 'gravityforms');
$card_number_label = gf_apply_filters(array('gform_card_number', $form_id), $card_number_label, $form_id);
$card_number_placeholder = $this->get_input_placeholder_attribute($card_number_field_input);
if ($is_sub_label_above) {
$card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n {$card_icons}\n <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n </span>";
} else {
$card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n {$card_icons}\n <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n </span>";
}
//expiration date field
$expiration_month_tab_index = $this->get_tabindex();
$expiration_year_tab_index = $this->get_tabindex();
$expiration_month_input = GFFormsModel::get_input($this, $this->id . '.2_month');
$expiration_month_placeholder = $this->get_input_placeholder_value($expiration_month_input);
$expiration_year_input = GFFormsModel::get_input($this, $this->id . '.2_year');
$expiration_year_placeholder = $this->get_input_placeholder_value($expiration_year_input);
$expiration_months = $this->get_expiration_months($expiration_month, $expiration_month_placeholder);
$expiration_years = $this->get_expiration_years($expiration_year, $expiration_year_placeholder);
$expiration_label = rgar($expiration_month_input, 'customLabel') != '' ? $expiration_month_input['customLabel'] : esc_html__('Expiration Date', 'gravityforms');
$expiration_label = gf_apply_filters(array('gform_card_expiration', $form_id), $expiration_label, $form_id);
if ($is_sub_label_above) {
$expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n <span class='ginput_card_expiration_container ginput_card_field'>\n <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n {$expiration_months}\n </select>\n <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n {$expiration_years}\n </select>\n </span>\n </span>";
} else {
$expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n <span class='ginput_card_expiration_container ginput_card_field'>\n <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n {$expiration_months}\n </select>\n <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n {$expiration_years}\n </select>\n <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n </span>\n </span>";
}
//security code field
$tabindex = $this->get_tabindex();
$security_code_field_input = GFFormsModel::get_input($this, $this->id . '.3');
$security_code_label = rgar($security_code_field_input, 'customLabel') != '' ? $security_code_field_input['customLabel'] : esc_html__('Security Code', 'gravityforms');
$security_code_label = gf_apply_filters(array('gform_card_security_code', $form_id), $security_code_label, $form_id);
$html5_output = GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
$security_code_placeholder = $this->get_input_placeholder_attribute($security_code_field_input);
if ($is_sub_label_above) {
//.........这里部分代码省略.........
示例9: get_field_input
public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
{
$id = $field["id"];
$field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
$form_id = IS_ADMIN && empty($form_id) ? rgget("id") : $form_id;
$size = rgar($field, "size");
$disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
$class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
$class = $size . $class_suffix;
$currency = "";
if (RG_CURRENT_VIEW == "entry") {
$lead = RGFormsModel::get_lead($lead_id);
$post_id = $lead["post_id"];
$post_link = "";
if (is_numeric($post_id) && self::is_post_field($field)) {
$post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
}
$currency = $lead["currency"];
}
$field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
if ($field_input) {
return $field_input;
}
//product fields are not editable
if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
return "<div class='ginput_container'>" . __("Product fields are not editable", "gravityforms") . "</div>";
} else {
if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
return "<div class='ginput_container'>" . __("Donations are not editable", "gravityforms") . "</div>";
}
}
// add categories as choices for Post Category field
if ($field['type'] == 'post_category') {
$field = self::add_categories_as_choices($field, $value);
}
$max_length = "";
$html5_attributes = "";
switch (RGFormsModel::get_input_type($field)) {
case "total":
if (RG_CURRENT_VIEW == "entry") {
return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
} else {
return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
}
break;
case "calculation":
case "singleproduct":
$product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
$price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
$quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
if (empty($price)) {
$price = 0;
}
$form = RGFormsModel::get_form_meta($form_id);
$has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
if ($has_quantity) {
$field["disableQuantity"] = true;
}
$quantity_field = "";
if (IS_ADMIN) {
$style = rgget("disableQuantity", $field) ? "style='display:none;'" : "";
$quantity_field = " <span class='ginput_quantity_label' {$style}>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
} else {
if (!rgget("disableQuantity", $field)) {
$tabindex = self::get_tabindex();
$quantity_field .= " <span class='ginput_quantity_label'>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
} else {
if (!is_numeric($quantity)) {
$quantity = 1;
}
if (!$has_quantity) {
$quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
}
}
}
return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='" . esc_attr($price) . "'/>{$quantity_field}</div>";
break;
case "hiddenproduct":
$form = RGFormsModel::get_form_meta($form_id);
$has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
$product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
$quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "1";
$price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
if (empty($price)) {
$price = 0;
}
$quantity_field = $has_quantity_field ? "" : "<input type='hidden' name='input_{$id}.3' value='" . esc_attr($quantity) . "' id='ginput_quantity_{$form_id}_{$field["id"]}' class='gform_hidden' />";
$product_name_field = "<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />";
$field_type = IS_ADMIN ? "text" : "hidden";
return $quantity_field . $product_name_field . sprintf("<input name='input_%d.2' id='ginput_base_price_{$form_id}_{$field["id"]}' type='{$field_type}' value='%s' class='gform_hidden ginput_amount' %s/>", $id, esc_attr($price), $disabled_text);
break;
case "singleshipping":
$price = !empty($value) ? $value : rgget("basePrice", $field);
if (empty($price)) {
$price = 0;
}
return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
break;
case "website":
$is_html5 = RGFormsModel::is_html5_enabled();
//.........这里部分代码省略.........
示例10: get_field_input
public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
{
$id = $field["id"];
$field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
$form_id = IS_ADMIN && empty($form_id) ? $_GET["id"] : $form_id;
$size = $field["size"];
$disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
$class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
$class = $size . $class_suffix;
$currency = "";
if (RG_CURRENT_VIEW == "entry") {
$lead = RGFormsModel::get_lead($lead_id);
$post_id = $lead["post_id"];
$post_link = "";
if (is_numeric($post_id) && self::is_post_field($field)) {
$post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
}
$currency = $lead["currency"];
}
$field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
if ($field_input) {
return $field_input;
}
//product fields are not editable
if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
return "<div class='ginput_container'>" . _e("Product fields are not editable", "gravityforms") . "</div>";
} else {
if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
return "<div class='ginput_container'>" . _e("Donations are not editable", "gravityforms") . "</div>";
}
}
$max_length = "";
$html5_attributes = "";
switch (RGFormsModel::get_input_type($field)) {
case "total":
if (RG_CURRENT_VIEW == "entry") {
return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
} else {
return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
}
break;
case "singleproduct":
$product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
$price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? $field["basePrice"] : esc_attr($value[$field["id"] . ".2"]);
$quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
if (empty($price)) {
$price = 0;
}
$form = RGFormsModel::get_form_meta($form_id);
$has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
if ($has_quantity) {
$field["disableQuantity"] = true;
}
$quantity_field = "";
if (IS_ADMIN) {
$style = $field["disableQuantity"] ? "style='display:none;'" : "";
$quantity_field = " <span class='ginput_quantity_label' {$style}>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
} else {
if (!$field["disableQuantity"]) {
$tabindex = self::get_tabindex();
$quantity_field .= " <span class='ginput_quantity_label'>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
} else {
if (!is_numeric($quantity)) {
$quantity = 1;
}
if (!$has_quantity) {
$quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
}
}
}
return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . __("Price:", "gravityformspaypal") . "</span> <span class='ginput_product_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='{$price}'/>{$quantity_field}</div>";
break;
case "singleshipping":
$price = !empty($value) ? $value : $field["basePrice"];
if (empty($price)) {
$price = 0;
}
return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
break;
case "website":
$is_html5 = RGFormsModel::is_html5_enabled();
$value = empty($value) && !$is_html5 ? "http://" : $value;
$html_input_type = $is_html5 ? "url" : "text";
$html5_attributes = $is_html5 ? "placeholder='http://'" : "";
case "text":
if (empty($html_input_type)) {
$html_input_type = "text";
}
if ($field["enablePasswordInput"] && RG_CURRENT_VIEW != "entry") {
$html_input_type = "password";
}
if (is_numeric($field["maxLength"])) {
$max_length = "maxlength='{$field["maxLength"]}'";
}
if (!empty($post_link)) {
return $post_link;
}
$tabindex = self::get_tabindex();
return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
break;
//.........这里部分代码省略.........
示例11: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$instruction = '';
$read_only = '';
if (!$is_entry_detail && !$is_form_editor) {
if ($this->has_calculation()) {
// calculation-enabled fields should be read only
$read_only = 'readonly="readonly"';
} else {
$message = $this->get_range_message();
$validation_class = $this->failed_validation ? 'validation_message' : '';
if (!$this->failed_validation && !empty($message) && empty($this->errorMessage)) {
$instruction = "<div class='instruction {$validation_class}'>" . $message . '</div>';
}
}
} elseif (RG_CURRENT_VIEW == 'entry') {
$value = GFCommon::format_number($value, $this->numberFormat, rgar($entry, 'currency'));
}
$is_html5 = RGFormsModel::is_html5_enabled();
$html_input_type = $is_html5 && !$this->has_calculation() && ($this->numberFormat != 'currency' && $this->numberFormat != 'decimal_comma') ? 'number' : 'text';
// chrome does not allow number fields to have commas, calculations and currency values display numbers with commas
$step_attr = $is_html5 ? "step='any'" : '';
$min = $this->rangeMin;
$max = $this->rangeMax;
$min_attr = $is_html5 && is_numeric($min) ? "min='{$min}'" : '';
$max_attr = $is_html5 && is_numeric($max) ? "max='{$max}'" : '';
$logic_event = $this->get_conditional_logic_event('keyup');
$include_thousands_sep = apply_filters('gform_include_thousands_sep_pre_format_number', $html_input_type == 'text', $this);
$value = GFCommon::format_number($value, $this->numberFormat, rgar($entry, 'currency'), $include_thousands_sep);
$placeholder_attribute = $this->get_field_placeholder_attribute();
$tabindex = $this->get_tabindex();
$input = sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' {$step_attr} {$min_attr} {$max_attr} value='%s' class='%s' {$tabindex} {$logic_event} {$read_only} %s %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $placeholder_attribute, $instruction);
return $input;
}
示例12: get_field_input
/**
* @param GF_Field $field
* @param string $value
* @param int $lead_id
* @param int $form_id
* @param null $form
*
* @return mixed|string|void
*/
public static function get_field_input($field, $value = '', $lead_id = 0, $form_id = 0, $form = null)
{
if (!$field instanceof GF_Field) {
$field = GF_Fields::create($field);
}
$is_form_editor = GFCommon::is_form_editor();
$is_entry_detail = GFCommon::is_entry_detail();
$is_admin = $is_form_editor || $is_entry_detail;
$id = intval($field->id);
$field_id = $is_admin || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_id = $is_admin && empty($form_id) ? rgget('id') : $form_id;
if (RG_CURRENT_VIEW == 'entry') {
$lead = RGFormsModel::get_lead($lead_id);
$post_id = $lead['post_id'];
$post_link = '';
if (is_numeric($post_id) && self::is_post_field($field)) {
$post_link = "<div>You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.</div>";
}
}
$field_input = apply_filters('gform_field_input', '', $field, $value, $lead_id, $form_id);
if ($field_input) {
return $field_input;
}
//product fields are not editable
if (RG_CURRENT_VIEW == 'entry' && self::is_product_field($field->type)) {
return "<div class='ginput_container'>" . esc_html__('Product fields are not editable', 'gravityforms') . '</div>';
} else {
if (RG_CURRENT_VIEW == 'entry' && $field->type == 'donation') {
return "<div class='ginput_container'>" . esc_html__('Donations are not editable', 'gravityforms') . '</div>';
}
}
// add categories as choices for Post Category field
if ($field->type == 'post_category') {
$field = self::add_categories_as_choices($field, $value);
}
$type = RGFormsModel::get_input_type($field);
switch ($type) {
case 'honeypot':
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
break;
case 'adminonly_hidden':
if (!is_array($field->inputs)) {
if (is_array($value)) {
$value = json_encode($value);
}
return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, esc_attr($field_id), esc_attr($value));
}
$fields = '';
foreach ($field->inputs as $input) {
$fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input['id'], esc_attr(rgar($value, strval($input['id']))));
}
return $fields;
break;
default:
if (!empty($post_link)) {
return $post_link;
}
if (!isset($lead)) {
$lead = null;
}
return $field->get_field_input($form, $value, $lead);
break;
}
}
示例13: is_gravityforms_html5_enabled
/**
* Checks whether the Gravity Forms html5 output is enabled.
*
* @return bool
*/
public function is_gravityforms_html5_enabled()
{
return class_exists("RGFormsModel") && RGFormsModel::is_html5_enabled();
}
示例14: get_field_input
public static function get_field_input($field, $value="", $lead_id=0, $form_id=0){
$id = $field["id"];
$field_id = IS_ADMIN || $form_id == 0 ? "input_$id" : "input_" . $form_id . "_$id";
$form_id = IS_ADMIN && empty($form_id) ? rgget("id") : $form_id;
$size = rgar($field, "size");
$disabled_text = (IS_ADMIN && RG_CURRENT_VIEW != "entry") ? "disabled='disabled'" : "";
$class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
$class = $size . $class_suffix;
$currency = "";
if(RG_CURRENT_VIEW == "entry"){
$lead = RGFormsModel::get_lead($lead_id);
$post_id = $lead["post_id"];
$post_link = "";
if(is_numeric($post_id) && self::is_post_field($field)){
$post_link = "You can <a href='post.php?action=edit&post=$post_id'>edit this post</a> from the post page.";
}
$currency = $lead["currency"];
}
$field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
if($field_input)
return $field_input;
//product fields are not editable
if(RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"]))
return "<div class='ginput_container'>" . __("Product fields are not editable", "gravityforms") . "</div>";
else if(RG_CURRENT_VIEW == "entry" && $field["type"] == "donation")
return "<div class='ginput_container'>" . __("Donations are not editable", "gravityforms") . "</div>";
// add categories as choices for Post Category field
if($field['type'] == 'post_category'){
$field = self::add_categories_as_choices($field, $value);
}
$max_length = "";
$html5_attributes = "";
switch(RGFormsModel::get_input_type($field)){
case "total" :
if(RG_CURRENT_VIEW == "entry")
return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
else
return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
break;
case "calculation" :
case "singleproduct" :
$product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
$price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
$quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
if(empty($price))
$price = 0;
$form = RGFormsModel::get_form_meta($form_id);
$has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
if($has_quantity)
$field["disableQuantity"] = true;
$quantity_field = "";
$qty_input_type = GFFormsModel::is_html5_enabled() ? "number" : "text";
if(IS_ADMIN){
$style = rgget("disableQuantity", $field) ? "style='display:none;'" : "";
$quantity_field = " <span class='ginput_quantity_label' {$style}>" . apply_filters("gform_product_quantity_{$form_id}",apply_filters("gform_product_quantity",__("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
}
else if(!rgget("disableQuantity", $field)){
$tabindex = self::get_tabindex();
$quantity_field .= " <span class='ginput_quantity_label'>" . apply_filters("gform_product_quantity_{$form_id}",apply_filters("gform_product_quantity",__("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
}
else{
if(!is_numeric($quantity))
$quantity = 1;
if(!$has_quantity){
$quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
}
}
return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price",__("Price", "gravityforms"), $form_id), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) ."</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='" . esc_attr($price) . "'/>{$quantity_field}</div>";
break;
case "hiddenproduct" :
$form = RGFormsModel::get_form_meta($form_id);
$has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
$product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
$quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "1";
$price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
if(empty($price))
$price = 0;
//.........这里部分代码省略.........
示例15: get_field_input
/**
* @param GF_Field $field
* @param string $value
* @param int $lead_id
* @param int $form_id
* @param null $form
*
* @return mixed|string|void
*/
public static function get_field_input($field, $value = '', $lead_id = 0, $form_id = 0, $form = null)
{
if (!$field instanceof GF_Field) {
$field = GF_Fields::create($field);
}
$field->adminOnly = false;
$id = intval($field->id);
$field_id = 'input_' . $form_id . "_{$id}";
$entry = RGFormsModel::get_lead($lead_id);
$post_id = $entry['post_id'];
$post_link = '';
if (is_numeric($post_id) && GFCommon::is_post_field($field)) {
$post_link = "<div>You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.</div>";
}
$field_input = apply_filters('gform_field_input', '', $field, $value, $lead_id, $form_id);
if ($field_input) {
return $field_input;
}
// add categories as choices for Post Category field
if ($field->type == 'post_category') {
$field = GFCommon::add_categories_as_choices($field, $value);
}
$type = RGFormsModel::get_input_type($field);
switch ($type) {
case 'honeypot':
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
break;
case 'adminonly_hidden':
if (!is_array($field->inputs)) {
if (is_array($value)) {
$value = json_encode($value);
}
return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
}
$fields = '';
foreach ($field->inputs as $input) {
$fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input['id'], esc_attr(rgar($value, strval($input['id']))));
}
return $fields;
break;
default:
if (!empty($post_link)) {
return $post_link;
}
if (!isset($entry)) {
$entry = null;
}
return $field->get_field_input($form, $value, $entry);
break;
}
}