本文整理汇总了PHP中GFFormDisplay::get_conditional_logic_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP GFFormDisplay::get_conditional_logic_fields方法的具体用法?PHP GFFormDisplay::get_conditional_logic_fields怎么用?PHP GFFormDisplay::get_conditional_logic_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFFormDisplay
的用法示例。
在下文中一共展示了GFFormDisplay::get_conditional_logic_fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show_edit_form
private function show_edit_form()
{
/*
* The user created the entry, so show them the form!
*/
if (self::$allowed_edit === false) {
/*
* TODO add error log message here
*/
return false;
}
ob_start();
$form = self::$form;
$lead = self::$lead;
$form_id = $form['id'];
$field_values = array();
$is_postback = false;
/*
* Validate form, if submitted
*/
if (isset($_POST['gform_submit'])) {
$is_postback = true;
$is_valid = $this->validate($form, $field_values);
if ($is_valid) {
/*
* TODO, save the form and show an update message
*/
if ($this->update_entry($form, $lead)) {
GFPDFEWidgetsAndShortcode_PDFDisplay::$message = __('Your entry and PDF(s) has been successfully updated.', 'pdfextended');
} else {
GFPDFEWidgetsAndShortcode_PDFDisplay::$error = __('There was a problem updating your entry. Please try again.', 'pdfextended');
}
return false;
}
}
?>
<div id="gform_wrapper_<?php
echo self::$form['id'];
?>
" class='gform_wrapper'>
<form id="gform_<?php
echo self::$form['id'];
?>
" method="post">
<div id='gform_page_<?php
echo self::$form['id'];
?>
_1'>
<div class='gform_page_fields'>
<?php
if ($is_postback && !$is_valid) {
$validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . " " . __("Errors have been highlighted below.", "gravityforms") . "</div>";
echo apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form);
}
?>
<ul id='gform_fields_<?php
echo self::$form['id'];
?>
' class='gform_fields'>
<?php
foreach ($form["fields"] as $field) {
$field_id = $field["id"];
/*
* If $field_id should be hidden...
*/
if (in_array($field_id, $this->atts['hidden_fields'])) {
continue;
}
$field["conditionalLogicFields"] = GFFormDisplay::get_conditional_logic_fields($form, $field["id"]);
$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(self::$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 = '_' . self::$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" : "";
$custom_class = IS_ADMIN ? "" : rgget("cssClass", $field);
$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_" . self::$form["id"], apply_filters("gform_field_css_class", trim($css_class), $field, self::$form), $field, self::$form);
$style = !empty($form) && !IS_ADMIN && RGFormsModel::is_field_hidden(self::$form, $field, $field_values) ? "style='display:none;'" : "";
switch (RGFormsModel::get_input_type($field)) {
case "captcha":
//.........这里部分代码省略.........
示例2: get_conditional_logic
private static function get_conditional_logic($form, $field_values = array())
{
$logics = '';
$dependents = '';
$fields_with_logic = array();
$default_values = array();
foreach ($form['fields'] as $field) {
/* @var GF_Field $field */
$field_deps = GFFormDisplay::get_conditional_logic_fields($form, $field->id);
$field_dependents[$field->id] = !empty($field_deps) ? $field_deps : array();
//use section's logic if one exists
$section = RGFormsModel::get_section($form, $field->id);
$section_logic = !empty($section) ? rgar($section, 'conditionalLogic') : null;
$field_logic = $field->type != 'page' ? $field->conditionalLogic : null;
//page break conditional logic will be handled during the next button click
$next_button_logic = !empty($field->nextButton) && !empty($field->nextButton['conditionalLogic']) ? $field->nextButton['conditionalLogic'] : null;
if (!empty($field_logic) || !empty($next_button_logic)) {
$field_section_logic = array('field' => $field_logic, 'nextButton' => $next_button_logic, 'section' => $section_logic);
$logics .= $field->id . ': ' . GFCommon::json_encode($field_section_logic) . ',';
$fields_with_logic[] = $field->id;
$peers = $field->type == 'section' ? GFCommon::get_section_fields($form, $field->id) : array($field);
$peer_ids = array();
foreach ($peers as $peer) {
$peer_ids[] = $peer->id;
}
$dependents .= $field->id . ': ' . GFCommon::json_encode($peer_ids) . ',';
}
//-- Saving default values so that they can be restored when toggling conditional logic ---
$field_val = '';
$input_type = $field->get_input_type();
$inputs = $field->get_entry_inputs();
//get parameter value if pre-populate is enabled
if ($field->allowsPrepopulate) {
if ($input_type == 'checkbox') {
$field_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
if (!is_array($field_val)) {
$field_val = explode(',', $field_val);
}
} elseif (is_array($inputs)) {
$field_val = array();
foreach ($inputs as $input) {
$field_val["input_{$input['id']}"] = RGFormsModel::get_parameter_value(rgar($input, 'name'), $field_values, $field);
}
} elseif ($input_type == 'time') {
// maintained for backwards compatibility. The Time field now has an inputs array.
$parameter_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
if (!empty($parameter_val) && preg_match('/^(\\d*):(\\d*) ?(.*)$/', $parameter_val, $matches)) {
$field_val = array();
$field_val[] = esc_attr($matches[1]);
//hour
$field_val[] = esc_attr($matches[2]);
//minute
$field_val[] = rgar($matches, 3);
//am or pm
}
} elseif ($input_type == 'list') {
$parameter_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
$field_val = is_array($parameter_val) ? $parameter_val : explode(',', str_replace('|', ',', $parameter_val));
if (is_array(rgar($field_val, 0))) {
$list_values = array();
foreach ($field_val as $row) {
$list_values = array_merge($list_values, array_values($row));
}
$field_val = $list_values;
}
} else {
$field_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
}
}
//use default value if pre-populated value is empty
$field_val = $field->get_value_default_if_empty($field_val);
if (is_array($field->choices) && $input_type != 'list') {
//radio buttons start at 0 and checkboxes start at 1
$choice_index = $input_type == 'radio' ? 0 : 1;
$is_pricing_field = GFCommon::is_pricing_field($field->type);
foreach ($field->choices as $choice) {
if ($input_type == 'checkbox' && $choice_index % 10 == 0) {
$choice_index++;
}
$is_prepopulated = is_array($field_val) ? in_array($choice['value'], $field_val) : $choice['value'] == $field_val;
$is_choice_selected = rgar($choice, 'isSelected') || $is_prepopulated;
if ($is_choice_selected && $input_type == 'select') {
$price = GFCommon::to_number(rgar($choice, 'price')) == false ? 0 : GFCommon::to_number(rgar($choice, 'price'));
$val = $is_pricing_field && $field->type != 'quantity' ? $choice['value'] . '|' . $price : $choice['value'];
$default_values[$field->id] = $val;
} elseif ($is_choice_selected) {
if (!isset($default_values[$field->id])) {
$default_values[$field->id] = array();
}
$default_values[$field->id][] = "choice_{$form['id']}_{$field->id}_{$choice_index}";
}
$choice_index++;
}
} elseif (!empty($field_val)) {
switch ($input_type) {
case 'date':
// for date fields; that are multi-input; and where the field value is a string
// (happens with prepop, default value will always be an array for multi-input date fields)
if (is_array($field->inputs) && (!is_array($field_val) || !isset($field_val['m']))) {
$format = empty($field->dateFormat) ? 'mdy' : esc_attr($field->dateFormat);
//.........这里部分代码省略.........