当前位置: 首页>>代码示例>>PHP>>正文


PHP GFCommon::has_field_calculation方法代码示例

本文整理汇总了PHP中GFCommon::has_field_calculation方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::has_field_calculation方法的具体用法?PHP GFCommon::has_field_calculation怎么用?PHP GFCommon::has_field_calculation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GFCommon的用法示例。


在下文中一共展示了GFCommon::has_field_calculation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare_value

 /**
  * Prepare the value before saving it to the lead.
  *
  * @param mixed $form
  * @param mixed $field
  * @param mixed $value
  * @param mixed $input_name
  * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
  * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function
  */
 public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
 {
     $form_id = $form["id"];
     $input_type = self::get_input_type($field);
     switch ($input_type) {
         case "total":
             $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
             $value = GFCommon::get_order_total($form, $lead);
             break;
         case "calculation":
             // ignore submitted value and recalculate price in backend
             list(, , $input_id) = rgexplode("_", $input_name, 3);
             if ($input_id == 2) {
                 require_once GFCommon::get_base_path() . '/currency.php';
                 $currency = new RGCurrency(GFCommon::get_currency());
                 $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
                 $value = $currency->to_money(GFCommon::calculate($field, $form, $lead));
             }
             break;
         case "phone":
             if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
                 $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
             }
             break;
         case "time":
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $value = array();
                 $value[0] = $matches[1];
                 $value[1] = $matches[2];
                 $value[2] = rgar($matches, 3);
             }
             $hour = empty($value[0]) ? "0" : strip_tags($value[0]);
             $minute = empty($value[1]) ? "0" : strip_tags($value[1]);
             $ampm = strip_tags(rgar($value, 2));
             if (!empty($ampm)) {
                 $ampm = " {$ampm}";
             }
             if (!(empty($hour) && empty($minute))) {
                 $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
             } else {
                 $value = "";
             }
             break;
         case "date":
             $value = self::prepare_date($field["dateFormat"], $value);
             break;
         case "post_image":
             $url = self::get_fileupload_value($form_id, $input_name);
             $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
             $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
             $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
             $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
             break;
         case "fileupload":
             $value = self::get_fileupload_value($form_id, $input_name);
             break;
         case "number":
             $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
             $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat"));
             //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false
             if (GFCommon::has_field_calculation($field) && $value == 0) {
                 $value = "0";
             }
             break;
         case "website":
             if ($value == "http://") {
                 $value = "";
             }
             break;
         case "list":
             if (GFCommon::is_empty_array($value)) {
                 $value = "";
             } else {
                 $value = self::create_list_array($field, $value);
                 $value = serialize($value);
             }
             break;
         case "radio":
             if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') {
                 $value = rgpost("input_{$field['id']}_other");
             }
             break;
         case "multiselect":
             $value = empty($value) ? "" : implode(",", $value);
             break;
         case "creditcard":
             //saving last 4 digits of credit card
             list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3);
             if ($input_id == "1") {
//.........这里部分代码省略.........
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:101,代码来源:forms_model.php

示例2: get_field

 public static function get_field($field, $value = "", $force_frontend_label = false, $form = null, $field_values = null)
 {
     $custom_class = IS_ADMIN ? "" : rgget("cssClass", $field);
     if ($field["type"] == "page") {
         if (IS_ADMIN && RG_CURRENT_VIEW == "entry") {
             return;
             //ignore page breaks in the entry detail page
         } else {
             if (!IS_ADMIN) {
                 $next_button = self::get_form_button($form["id"], "gform_next_button_{$form["id"]}_{$field["id"]}", $field["nextButton"], __("Next", "gravityforms"), "button gform_next_button", __("Next Page", "gravityforms"), $field["pageNumber"]);
                 $previous_button = $field["pageNumber"] == 2 ? "" : self::get_form_button($form["id"], "gform_previous_button_{$form["id"]}_{$field["id"]}", $field["previousButton"], __("Previous", "gravityforms"), "button gform_previous_button", __("Previous Page", "gravityforms"), $field["pageNumber"] - 2);
                 $style = self::is_page_active($form["id"], $field["pageNumber"]) ? "" : "style='display:none;'";
                 $custom_class = !empty($custom_class) ? " {$custom_class}" : "";
                 $html = "</ul>\n                    </div>\n                    <div class='gform_page_footer'>\n                        {$previous_button} {$next_button}\n                    </div>\n                </div>\n                <div id='gform_page_{$form["id"]}_{$field["pageNumber"]}' class='gform_page{$custom_class}' {$style}>\n                    <div class='gform_page_fields'>\n                        <ul class='gform_fields {$form['labelPlacement']}'>";
                 return $html;
             }
         }
     }
     if ($field["type"] == "post_category") {
     }
     if (!IS_ADMIN && rgar($field, "adminOnly")) {
         if ($field["allowsPrepopulate"]) {
             $field["inputType"] = "adminonly_hidden";
         } else {
             return;
         }
     }
     $id = $field["id"];
     $type = $field["type"];
     $input_type = RGFormsModel::get_input_type($field);
     $error_class = rgget("failed_validation", $field) ? "gfield_error" : "";
     $admin_only_class = rgget("adminOnly", $field) ? "field_admin_only" : "";
     $selectable_class = IS_ADMIN ? "selectable" : "";
     $hidden_class = in_array($input_type, array("hidden", "hiddenproduct")) ? "gform_hidden" : "";
     $section_class = $field["type"] == "section" ? "gsection" : "";
     $page_class = $field["type"] == "page" ? "gpage" : "";
     $html_block_class = $field["type"] == "html" ? "gfield_html" : "";
     $html_formatted_class = $field["type"] == "html" && !IS_ADMIN && !rgget("disableMargins", $field) ? "gfield_html_formatted" : "";
     $html_no_follows_desc_class = $field["type"] == "html" && !IS_ADMIN && !self::prev_field_has_description($form, $field["id"]) ? "gfield_no_follows_desc" : "";
     $calculation_class = RGFormsModel::get_input_type($field) == 'number' && GFCommon::has_field_calculation($field) ? 'gfield_calculation' : '';
     $calculation_class = RGFormsModel::get_input_type($field) == 'calculation' ? 'gfield_calculation' : '';
     $product_suffix = "_{$form["id"]}_" . rgget("productField", $field);
     $option_class = $field["type"] == "option" ? "gfield_price gfield_price{$product_suffix} gfield_option{$product_suffix}" : "";
     $quantity_class = $field["type"] == "quantity" ? "gfield_price gfield_price{$product_suffix} gfield_quantity{$product_suffix}" : "";
     $shipping_class = $field["type"] == "shipping" ? "gfield_price gfield_shipping gfield_shipping_{$form["id"]}" : "";
     $product_class = $field["type"] == "product" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_product_{$form["id"]}_{$field["id"]}" : "";
     $hidden_product_class = $input_type == "hiddenproduct" ? "gfield_hidden_product" : "";
     $donation_class = $field["type"] == "donation" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_donation_{$form["id"]}_{$field["id"]}" : "";
     $required_class = rgar($field, "isRequired") ? "gfield_contains_required" : "";
     $creditcard_warning_class = $input_type == "creditcard" && !GFCommon::is_ssl() ? "gfield_creditcard_warning" : "";
     $css_class = "{$selectable_class} gfield {$error_class} {$section_class} {$admin_only_class} {$custom_class} {$hidden_class} {$html_block_class} {$html_formatted_class} {$html_no_follows_desc_class} {$option_class} {$quantity_class} {$product_class} {$donation_class} {$shipping_class} {$page_class} {$required_class} {$hidden_product_class} {$creditcard_warning_class} {$calculation_class}";
     $css_class = apply_filters("gform_field_css_class_{$form["id"]}", apply_filters("gform_field_css_class", trim($css_class), $field, $form), $field, $form);
     $style = !empty($form) && !IS_ADMIN && RGFormsModel::is_field_hidden($form, $field, $field_values) ? "style='display:none;'" : "";
     $field_id = IS_ADMIN || empty($form) ? "field_{$id}" : "field_" . $form["id"] . "_{$id}";
     return "<li id='{$field_id}' class='{$css_class}' {$style}>" . self::get_field_content($field, $value, $force_frontend_label, $form == null ? 0 : $form["id"]) . "</li>";
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:56,代码来源:form_display.php

示例3: get_field_input


//.........这里部分代码省略.........
         case "hidden":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $field_type = IS_ADMIN ? "text" : "hidden";
             $class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
             return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
             break;
         case "html":
             $content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
             $content = GFCommon::replace_variables_prepopulate($content);
             //adding support for merge tags
             $content = do_shortcode($content);
             //adding support for shortcodes
             return $content;
             break;
         case "adminonly_hidden":
             if (!is_array($field["inputs"])) {
                 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, $input["id"])));
             }
             return $fields;
             break;
         case "number":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = "";
             $read_only = "";
             if (!IS_ADMIN) {
                 if (GFCommon::has_field_calculation($field)) {
                     // calculation-enabled fields should be read only
                     $read_only = 'readonly="readonly"';
                 } else {
                     $message = self::get_range_message($field);
                     $validation_class = $field["failed_validation"] ? "validation_message" : "";
                     if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
                         $instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
                     }
                 }
             }
             $is_html5 = RGFormsModel::is_html5_enabled();
             $html_input_type = $is_html5 && !GFCommon::has_field_calculation($field) ? "number" : "text";
             // chrome does not allow number fields to have commas, calculations display numbers with commas
             $step_attr = $is_html5 ? "step='any'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' {$step_attr} value='%s' class='%s' {$tabindex} {$logic_event} {$read_only} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $instruction);
         case "donation":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_donation_amount' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "price":
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_amount' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "phone":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = $field["phoneFormat"] == "standard" ? __("Phone format:", "gravityforms") . " (###)###-####" : "";
             $instruction_div = rgget("failed_validation", $field) ? "<div class='instruction validation_message'>{$instruction}</div>" : "";
             $html_input_type = RGFormsModel::is_html5_enabled() ? "tel" : "text";
             $logic_event = self::get_logic_event($field, "keyup");
开发者ID:ipman3,项目名称:Mediassociates-wp,代码行数:67,代码来源:common.php

示例4: validate


//.........这里部分代码省略.........
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "email":
                             if (!rgblank($value) && !GFCommon::is_valid_email($value)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
                             } else {
                                 if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
                                     $confirm = rgpost("input_" . $field["id"] . "_2");
                                     if ($confirm != $value) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = __("Your emails do not match.", "gravityforms");
                                     }
                                 }
                             }
                             break;
                         case "price":
                             if (!class_exists("RGCurrency")) {
                                 require_once "currency.php";
                             }
                             $donation = GFCommon::to_number($value);
                             if (!rgblank($value) && ($donation === false || $donation < 0)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid amount.", "gravityforms") : $field["errorMessage"];
                             }
                             break;
                         case "number":
                             // the POST value has already been converted from currency or decimal_comma to decimal_dot and then cleaned in get_field_value()
                             $value = GFCommon::maybe_add_leading_zero($value);
                             $raw_value = $_POST["input_" . $field["id"]];
                             //Raw value will be tested against the is_numeric() function to make sure it is in the right format.
                             $requires_valid_number = !rgblank($raw_value) && !GFCommon::has_field_calculation($field);
                             $is_valid_number = self::validate_range($field, $value) && GFCommon::is_numeric($raw_value, $field["numberFormat"]);
                             if ($requires_valid_number && !$is_valid_number) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
                             } else {
                                 if ($field['type'] == 'quantity') {
                                     if (intval($value) != $value) {
                                         $field['failed_validation'] = true;
                                         $field['validation_message'] = empty($field['errorMessage']) ? __('Please enter a valid quantity. Quantity cannot contain decimals.', 'gravityforms') : $field['errorMessage'];
                                     } else {
                                         if (!empty($value) && (!is_numeric($value) || intval($value) != floatval($value) || intval($value) < 0)) {
                                             $field['failed_validation'] = true;
                                             $field['validation_message'] = empty($field['errorMessage']) ? __('Please enter a valid quantity', 'gravityforms') : $field['errorMessage'];
                                         }
                                     }
                                 }
                             }
                             break;
                         case "phone":
                             $regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
                             if ($field["phoneFormat"] == "standard" && $value !== "" && $value !== 0 && !preg_match($regex, $value)) {
                                 $field["failed_validation"] = true;
                                 if (!empty($field["errorMessage"])) {
                                     $field["validation_message"] = $field["errorMessage"];
                                 }
                             }
                             break;
                         case "date":
                             if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
                                 $value = null;
                             }
                             if (!empty($value)) {
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:67,代码来源:entry-edit-logic.php

示例5: prepare_value


//.........这里部分代码省略.........
                 if (isset($_gf_uploaded_files[$input_name])) {
                     $value = $_gf_uploaded_files[$input_name];
                 } else {
                     if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) {
                         $uploaded_temp_files = GFFormsModel::$uploaded_files[$form_id][$input_name];
                         $uploaded_files = array();
                         foreach ($uploaded_temp_files as $i => $file_info) {
                             $temp_filepath = self::get_upload_path($form_id) . '/tmp/' . $file_info['temp_filename'];
                             if ($file_info && file_exists($temp_filepath)) {
                                 $uploaded_files[$i] = self::move_temp_file($form_id, $file_info);
                             }
                         }
                         if (!empty($value)) {
                             // merge with existing files (admin edit entry)
                             $value = json_decode($value, true);
                             $value = array_merge($value, $uploaded_files);
                             $value = json_encode($value);
                         } else {
                             $value = json_encode($uploaded_files);
                         }
                     } else {
                         $value = '';
                     }
                     $_gf_uploaded_files[$input_name] = $value;
                 }
             } else {
                 $value = self::get_fileupload_value($form_id, $input_name);
             }
             break;
         case "number":
             $value = GFCommon::maybe_add_leading_zero($value);
             $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
             $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
             $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat"));
             //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false
             if (GFCommon::has_field_calculation($field) && $value == 0) {
                 $value = "0";
             }
             break;
         case "website":
             if ($value == "http://") {
                 $value = "";
             }
             break;
         case "list":
             if (rgar($field, "adminOnly") && rgar($field, "allowsPrepopulate")) {
                 $value = json_decode($value);
             }
             if (GFCommon::is_empty_array($value)) {
                 $value = "";
             } else {
                 foreach ($value as &$val) {
                     $val = self::sanitize_entry_value($field, $val, $input_type, $form_id);
                 }
                 $value = self::create_list_array($field, $value);
                 $value = serialize($value);
             }
             break;
         case "radio":
             if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') {
                 $value = rgpost("input_{$field['id']}_other");
             }
             $value = self::sanitize_entry_value($field, $value, $input_type, $form_id);
             break;
         case "multiselect":
             $value = empty($value) ? "" : is_array($value) ? implode(",", $value) : $value;
开发者ID:BisongT,项目名称:Myevent_website,代码行数:67,代码来源:forms_model.php

示例6: save_lead

 /**
  * Adapted from forms_model.php, RGFormsModel::save_lead($Form, $lead)
  * @param  array $form Form object.
  * @param  array $lead Lead object
  * @return void
  */
 public static function save_lead($form, &$lead)
 {
     global $wpdb;
     if (IS_ADMIN && !GFCommon::current_user_can_any("gravityforms_edit_entries")) {
         die(__("You don't have adequate permission to edit entries.", "gravityforms"));
     }
     $lead_detail_table = RGFormsModel::get_lead_details_table_name();
     //Inserting lead if null
     if ($lead == null) {
         global $current_user;
         $user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
         $lead_table = RGFormsModel::get_lead_table_name();
         $user_agent = RGFormsModel::truncate($_SERVER["HTTP_USER_AGENT"], 250);
         $currency = GFCommon::get_currency();
         $source_url = RGFormsModel::truncate(RGFormsModel::get_current_page_url(), 200);
         $wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form["id"], RGFormsModel::get_ip(), $source_url, $user_agent, $currency));
         //reading newly created lead id
         $lead_id = $wpdb->insert_id;
         $lead = array("id" => $lead_id);
     }
     $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead["id"]));
     $original_post_id = rgget("post_id", $lead);
     $total_fields = array();
     $calculation_fields = array();
     $recalculate_total = false;
     foreach ($form["fields"] as $field) {
         //Ignore fields that are marked as display only
         if (rgget("displayOnly", $field) && $field["type"] != "password") {
             continue;
         }
         //ignore pricing fields in the entry detail
         if (RG_CURRENT_VIEW == "entry" && GFCommon::is_pricing_field($field["type"])) {
             continue;
         }
         //process total field after all fields have been saved
         if ($field["type"] == "total") {
             $total_fields[] = $field;
             continue;
         }
         //only save fields that are not hidden (except on entry screen)
         if (RG_CURRENT_VIEW == "entry" || !RGFormsModel::is_field_hidden($form, $field, array(), $lead)) {
             // process calculation fields after all fields have been saved (moved after the is hidden check)
             if (GFCommon::has_field_calculation($field)) {
                 $calculation_fields[] = $field;
                 continue;
             }
             if ($field['type'] == 'post_category') {
                 $field = GFCommon::add_categories_as_choices($field, '');
             }
             if (isset($field["inputs"]) && is_array($field["inputs"])) {
                 foreach ($field["inputs"] as $input) {
                     RGFormsModel::save_input($form, $field, $lead, $current_fields, $input["id"]);
                 }
             } else {
                 RGFormsModel::save_input($form, $field, $lead, $current_fields, $field["id"]);
             }
         }
         //Refresh lead to support conditionals (not optimal but...)
         $lead = RGFormsModel::get_lead($lead['id']);
     }
     if (!empty($calculation_fields)) {
         foreach ($calculation_fields as $calculation_field) {
             if (isset($calculation_field["inputs"]) && is_array($calculation_field["inputs"])) {
                 foreach ($calculation_field["inputs"] as $input) {
                     RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $input["id"]);
                     RGFormsModel::refresh_lead_field_value($lead["id"], $input["id"]);
                 }
             } else {
                 RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field["id"]);
                 RGFormsModel::refresh_lead_field_value($lead["id"], $calculation_field["id"]);
             }
         }
         RGFormsModel::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
     }
     //saving total field as the last field of the form.
     if (!empty($total_fields)) {
         foreach ($total_fields as $total_field) {
             GFCommon::log_debug("Saving total field.");
             RGFormsModel::save_input($form, $total_field, $lead, $current_fields, $total_field["id"]);
         }
     }
 }
开发者ID:healthcommcore,项目名称:osnap,代码行数:88,代码来源:gravity-forms-addons.php

示例7: get_field_input


//.........这里部分代码省略.........
            break;

            case "html" :
                $content = IS_ADMIN ? "<div class='gf-html-container'><span class='gf_blockheader'><i class='fa fa-code fa-lg'></i> " . __("HTML Content", "gravityforms") . "</span><span>" . __("This is a content placeholder. HTML content is not displayed in the form admin. Preview this form to view the content.", "gravityforms") . "</span></div>" : $field["content"];
                $content = GFCommon::replace_variables_prepopulate($content); //adding support for merge tags
                $content = do_shortcode($content); //adding support for shortcodes
                return $content;
            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;

            case "number" :
                if(!empty($post_link))
                    return $post_link;

                $instruction = "";
                $read_only = "";

                if(!IS_ADMIN){

                    if(GFCommon::has_field_calculation($field)) {

                        // calculation-enabled fields should be read only
                        $read_only = 'readonly="readonly"';

                    } else {

                        $message = self::get_range_message($field);
                        $validation_class = $field["failed_validation"] ? "validation_message" : "";

                        if(!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"]))
                            $instruction = "<div class='instruction $validation_class'>" . $message . "</div>";

                    }

                }
                else if( RG_CURRENT_VIEW == "entry" ){
                    $value = GFCommon::format_number($value, rgar($field, "numberFormat"));
                }

                $is_html5 = RGFormsModel::is_html5_enabled();
                $html_input_type = $is_html5 && !GFCommon::has_field_calculation($field) && ($field["numberFormat"] != "currency" && $field["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'" : "";

                $logic_event = self::get_logic_event($field, "keyup");

                $value = GFCommon::format_number($value, $field["numberFormat"]);

                $tabindex = self::get_tabindex();
                return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' {$step_attr} value='%s' class='%s' {$tabindex} {$logic_event} {$read_only} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class),  $disabled_text, $instruction);

            case "donation" :
                $tabindex = self::get_tabindex();
开发者ID:bmontague,项目名称:sct,代码行数:67,代码来源:common.php


注:本文中的GFCommon::has_field_calculation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。