本文整理汇总了PHP中RGFormsModel::get_field_value方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_field_value方法的具体用法?PHP RGFormsModel::get_field_value怎么用?PHP RGFormsModel::get_field_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_field_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_post_categories
/**
* Update the post categories based on all post category fields
*
* @since 1.17
*
* @param array $form Gravity Forms form array
* @param int $entry_id Numeric ID of the entry that was updated
*
* @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
*/
public function set_post_categories($form = array(), $entry_id = 0)
{
$entry = GFAPI::get_entry($entry_id);
$post_id = rgar($entry, 'post_id');
if (empty($post_id)) {
return false;
}
$return = false;
$post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
if ($post_category_fields) {
$updated_categories = array();
foreach ($post_category_fields as $field) {
// Get the value of the field, including $_POSTed value
$field_cats = RGFormsModel::get_field_value($field);
$field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
$field_cats = gv_map_deep($field_cats, 'intval');
$updated_categories = array_merge($updated_categories, array_values($field_cats));
}
// Remove `0` values from intval()
$updated_categories = array_filter($updated_categories);
/**
* @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
* @since 1.17
* @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
*/
$append = apply_filters('gravityview/edit_entry/post_categories/append', false);
$return = wp_set_post_categories($post_id, $updated_categories, $append);
}
return $return;
}
示例2: is_condition_true
/**
* Check if the iDEAL condition is true
*
* @param mixed $form
* @param mixed $feed
*/
public static function is_condition_true($form, $feed)
{
if (!$feed->condition_enabled) {
return true;
}
$field = RGFormsModel::get_field($form, $feed->condition_field_id);
// Unknown field
if (empty($field)) {
return true;
}
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
// Ignore condition if the field is hidden
if ($is_hidden) {
return false;
}
$value = RGFormsModel::get_field_value($field, array());
$is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
switch ($feed->condition_operator) {
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
$result = $is_match;
break;
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
$result = !$is_match;
break;
default:
$result = true;
}
return $result;
}
示例3: is_condition_true
/**
* Check if the iDEAL condition is true
*
* @param mixed $form
* @param mixed $feed
*/
public static function is_condition_true($form, $feed)
{
$result = true;
if ($feed->condition_enabled) {
$field = RGFormsModel::get_field($form, $feed->condition_field_id);
if (empty($field)) {
// unknown field
$result = true;
} else {
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
if ($is_hidden) {
// if conditional is enabled, but the field is hidden, ignore conditional
$result = false;
} else {
$value = RGFormsModel::get_field_value($field, array());
$is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
switch ($feed->condition_operator) {
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
$result = $is_match;
break;
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
$result = !$is_match;
break;
default:
// unknown operator
$result = true;
break;
}
}
}
} else {
// condition is disabled, result is true
$result = true;
}
return $result;
}
示例4: validate
public static function validate(&$form, $field_values, $page_number = 0)
{
$is_valid = true;
foreach ($form["fields"] as &$field) {
//If a page number is specified, only validates fields that are on current page
if ($page_number > 0 && $field["pageNumber"] != $page_number) {
continue;
}
//ignore validation if field is hidden or admin only
if (RGFormsModel::is_field_hidden($form, $field, $field_values) || $field["adminOnly"]) {
continue;
}
$value = RGFormsModel::get_field_value($field);
//display error message if field is marked as required and the submitted value is empty
if ($field["isRequired"] && self::is_empty($field, $form["id"])) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
} else {
if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = is_array($value) ? apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", __("This field requires an unique entry and the values you entered have been already been used", "gravityforms"), $form), $form) : apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", sprintf(__("This field requires an unique entry and '%s' has already been used", "gravityforms"), $value), $form), $form);
$is_valid = false;
} else {
if (self::failed_state_validation($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = in_array($field["inputType"], array("singleproduct", "singleshipping")) ? __("Please enter a valid value.", "gravityforms") : __("Invalid selection. Please select one of the available choices.", "gravityforms");
$is_valid = false;
} else {
switch (RGFormsModel::get_input_type($field)) {
case "password":
$password = $_POST["input_" . $field["id"]];
$confirm = $_POST["input_" . $field["id"] . "_2"];
if ($password != $confirm) {
$field["failed_validation"] = true;
$field["validation_message"] = __("Your passwords do not match.", "gravityforms");
$is_valid = false;
} else {
if ($field["passwordStrengthEnabled"] && !empty($field["minPasswordStrength"]) && !empty($password)) {
$strength = $_POST["input_" . $field["id"] . "_strength"];
$levels = array("short" => 1, "bad" => 2, "good" => 3, "strong" => 4);
if ($levels[$strength] < $levels[$field["minPasswordStrength"]]) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Your password does not meet the required strength. <br/>Hint: To make it stronger, use upper and lower case letters, numbers and symbols like ! \" ? \$ % ^ & ).", "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
}
break;
case "name":
if ($field["isRequired"] && $field["nameFormat"] != "simple") {
$first = $_POST["input_" . $field["id"] . "_3"];
$last = $_POST["input_" . $field["id"] . "_6"];
if (empty($first) || empty($last)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
break;
case "address":
if ($field["isRequired"]) {
$street = $_POST["input_" . $field["id"] . "_1"];
$city = $_POST["input_" . $field["id"] . "_3"];
$state = $_POST["input_" . $field["id"] . "_4"];
$zip = $_POST["input_" . $field["id"] . "_5"];
$country = $_POST["input_" . $field["id"] . "_6"];
if (empty($street) || empty($city) || empty($zip) || empty($state) && !$field["hideState"] || empty($country) && !$field["hideCountry"]) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
break;
case "email":
if (!empty($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"];
$is_valid = false;
} 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");
$is_valid = false;
}
}
}
break;
case "donation":
case "price":
if (!class_exists("RGCurrency")) {
require_once "currency.php";
}
$donation = GFCommon::to_number($value);
if (!empty($value) && ($donation === false || $donation <= 0)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid donation", "gravityforms") : $field["errorMessage"];
$is_valid = false;
//.........这里部分代码省略.........
示例5: conditions_met
public static function conditions_met($form, $zap)
{
$zap = $zap["meta"];
$operator = isset($zap["zapier_conditional_operator"]) ? $zap["zapier_conditional_operator"] : "";
$field = RGFormsModel::get_field($form, $zap["zapier_conditional_field_id"]);
if (empty($field) || !$zap["zapier_conditional_enabled"]) {
return true;
}
// if conditional is enabled, but the field is hidden, ignore conditional
$is_visible = !RGFormsModel::is_field_hidden($form, $field, array());
$field_value = RGFormsModel::get_field_value($field, array());
$is_value_match = RGFormsModel::is_value_match($field_value, $zap["zapier_conditional_value"], $operator);
$go_to_zapier = $is_value_match && $is_visible;
return $go_to_zapier;
}
示例6: validate
public static function validate(&$form, $field_values, $page_number = 0, &$failed_validation_page = 0)
{
$form = apply_filters('gform_pre_validation', $form);
// validate form schedule
if (self::validate_form_schedule($form)) {
return false;
}
// validate entry limit
if (self::validate_entry_limit($form)) {
return false;
}
foreach ($form["fields"] as &$field) {
//If a page number is specified, only validates fields that are on current page
$field_in_other_page = $page_number > 0 && $field["pageNumber"] != $page_number;
//validate fields with "no duplicate" functionality when they are present on pages before the current page.
$validate_duplicate_feature = $field["noDuplicates"] && $page_number > 0 && $field["pageNumber"] <= $page_number;
if ($field_in_other_page && !$validate_duplicate_feature) {
continue;
}
//ignore validation if field is hidden or admin only
if (RGFormsModel::is_field_hidden($form, $field, $field_values) || $field["adminOnly"]) {
continue;
}
$value = RGFormsModel::get_field_value($field);
//display error message if field is marked as required and the submitted value is empty
if ($field["isRequired"] && self::is_empty($field, $form["id"])) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required.", "gravityforms") : $field["errorMessage"];
} else {
if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
$field["failed_validation"] = true;
//set page number so the failed field displays if on multi-page form
$failed_validation_page = $field["pageNumber"];
$input_type = RGFormsModel::get_input_type($field);
switch ($input_type) {
case "date":
$default_message = __("This date has already been taken. Please select a new date.", "gravityforms");
break;
default:
$default_message = is_array($value) ? __("This field requires an unique entry and the values you entered have been already been used.", "gravityforms") : sprintf(__("This field requires an unique entry and '%s' has already been used", "gravityforms"), $value);
break;
}
$field["validation_message"] = apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", $default_message, $form), $form);
} else {
if (self::failed_state_validation($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = in_array($field["inputType"], array("singleproduct", "singleshipping", "hiddenproduct")) ? __("Please enter a valid value.", "gravityforms") : __("Invalid selection. Please select one of the available choices.", "gravityforms");
} else {
switch (RGFormsModel::get_input_type($field)) {
case "password":
$password = $_POST["input_" . $field["id"]];
$confirm = $_POST["input_" . $field["id"] . "_2"];
if ($password != $confirm) {
$field["failed_validation"] = true;
$field["validation_message"] = __("Your passwords do not match.", "gravityforms");
} else {
if (rgar($field, "passwordStrengthEnabled") && !rgempty("minPasswordStrength", $field) && !empty($password)) {
$strength = $_POST["input_" . $field["id"] . "_strength"];
$levels = array("short" => 1, "bad" => 2, "good" => 3, "strong" => 4);
if ($levels[$strength] < $levels[$field["minPasswordStrength"]]) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Your password does not meet the required strength. <br/>Hint: To make it stronger, use upper and lower case letters, numbers and symbols like ! \" ? \$ % ^ & ).", "gravityforms") : $field["errorMessage"];
}
}
}
break;
case "name":
if ($field["isRequired"] && $field["nameFormat"] != "simple") {
$first = $_POST["input_" . $field["id"] . "_3"];
$last = $_POST["input_" . $field["id"] . "_6"];
if (empty($first) || empty($last)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
}
}
break;
case "address":
if ($field["isRequired"]) {
$street = $_POST["input_" . $field["id"] . "_1"];
$city = $_POST["input_" . $field["id"] . "_3"];
$state = $_POST["input_" . $field["id"] . "_4"];
$zip = $_POST["input_" . $field["id"] . "_5"];
$country = $_POST["input_" . $field["id"] . "_6"];
if (empty($street) || empty($city) || empty($zip) || empty($state) && !$field["hideState"] || empty($country) && !$field["hideCountry"]) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
}
}
break;
case "creditcard":
$card_number = rgpost("input_" . $field["id"] . "_1");
$expiration_date = rgpost("input_" . $field["id"] . "_2");
$security_code = rgpost("input_" . $field["id"] . "_3");
if (rgar($field, "isRequired") && (empty($card_number) || empty($security_code) || empty($expiration_date[0]) || empty($expiration_date[1]))) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter your credit card information.", "gravityforms") : $field["errorMessage"];
} else {
if (!empty($card_number)) {
$card_type = GFCommon::get_card_type($card_number);
$security_code = rgpost("input_" . $field["id"] . "_3");
//.........这里部分代码省略.........
示例7: has_paypal_condition
public static function has_paypal_condition($form, $config)
{
$config = $config["meta"];
$operator = isset($config["paypal_conditional_operator"]) ? $config["paypal_conditional_operator"] : "";
$field = RGFormsModel::get_field($form, $config["paypal_conditional_field_id"]);
if (empty($field) || !$config["paypal_conditional_enabled"]) {
return true;
}
// if conditional is enabled, but the field is hidden, ignore conditional
$is_visible = !RGFormsModel::is_field_hidden($form, $field, array());
$field_value = RGFormsModel::get_field_value($field, array());
$is_value_match = RGFormsModel::is_value_match($field_value, $config["paypal_conditional_value"], $operator);
$go_to_paypal = $is_value_match && $is_visible;
return $go_to_paypal;
}
示例8: custom_validation
/**
* Make validation work for Edit Entry
*
* Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end
* form pretending to be a back-end form), validate() doesn't know we _can't_ edit post
* fields. This goes through all the fields and if they're an invalid post field, we
* set them as valid. If there are still issues, we'll return false.
*
* @param [type] $validation_results [description]
* @return [type] [description]
*/
function custom_validation($validation_results)
{
do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results);
do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html(print_r($_POST, true)));
$gv_valid = true;
foreach ($validation_results['form']['fields'] as $key => &$field) {
$value = RGFormsModel::get_field_value($field);
$field_type = RGFormsModel::get_input_type($field);
// Validate always
switch ($field_type) {
case 'fileupload':
// in case nothing is uploaded but there are already files saved
if (!empty($field->failed_validation) && !empty($field->isRequired) && !empty($value)) {
$field->failed_validation = false;
unset($field->validation_message);
}
// validate if multi file upload reached max number of files [maxFiles] => 2
if (rgar($field, 'maxFiles') && rgar($field, 'multipleFiles')) {
$input_name = 'input_' . $field->id;
//uploaded
$file_names = isset(GFFormsModel::$uploaded_files[$validation_results['form']['id']][$input_name]) ? GFFormsModel::$uploaded_files[$validation_results['form']['id']][$input_name] : array();
//existent
$entry = $this->get_entry();
$value = NULL;
if (isset($entry[$field->id])) {
$value = json_decode($entry[$field->id], true);
}
// count uploaded files and existent entry files
$count_files = count($file_names) + count($value);
if ($count_files > $field->maxFiles) {
$field->validation_message = __('Maximum number of files reached', 'gravityview');
$field->failed_validation = 1;
$gv_valid = false;
// in case of error make sure the newest upload files are removed from the upload input
GFFormsModel::$uploaded_files[$validation_results['form']['id']] = null;
}
}
break;
}
// This field has failed validation.
if (!empty($field->failed_validation)) {
do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array('field' => $field, 'value' => $value));
switch ($field_type) {
// Captchas don't need to be re-entered.
case 'captcha':
// Post Image fields aren't editable, so we un-fail them.
// Post Image fields aren't editable, so we un-fail them.
case 'post_image':
$field->failed_validation = false;
unset($field->validation_message);
break;
}
// You can't continue inside a switch, so we do it after.
if (empty($field->failed_validation)) {
continue;
}
// checks if the No Duplicates option is not validating entry against itself, since
// we're editing a stored entry, it would also assume it's a duplicate.
if (!empty($field->noDuplicates)) {
$entry = $this->get_entry();
// If the value of the entry is the same as the stored value
// Then we can assume it's not a duplicate, it's the same.
if (!empty($entry) && $value == $entry[$field->id]) {
//if value submitted was not changed, then don't validate
$field->failed_validation = false;
unset($field->validation_message);
do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry);
continue;
}
}
// if here then probably we are facing the validation 'At least one field must be filled out'
if (GFFormDisplay::is_empty($field, $this->form_id) && empty($field->isRequired)) {
unset($field->validation_message);
$field->validation_message = false;
continue;
}
$gv_valid = false;
}
}
$validation_results['is_valid'] = $gv_valid;
do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results);
// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
$this->form_after_validation = $validation_results['form'];
return $validation_results;
}
示例9: assign_group_allowed
public static function assign_group_allowed($form, $settings, $grouping, $group)
{
$config = $settings["meta"];
$operator = $config["groups"][$grouping][$group]["operator"];
$decision = $config["groups"][$grouping][$group]["decision"];
$field = RGFormsModel::get_field($form, $config["groups"][$grouping][$group]["field_id"]);
$field_value = RGFormsModel::get_field_value($field, array());
$is_value_match = RGFormsModel::is_value_match($field_value, $config["groups"][$grouping][$group]["value"]);
if (!$config["groups"][$grouping][$group]["enabled"]) {
return false;
} else {
if ($decision == "always" || empty($field)) {
return true;
} else {
if ($decision == "if" && ($operator == "is" && $is_value_match || $operator == "isnot" && !$is_value_match)) {
return true;
}
}
}
return false;
}
示例10: has_stripe_condition
/**
* @param $form
* @param $feed
*
* @return bool
*/
public function has_stripe_condition($form, $feed)
{
$feed = $feed['meta'];
$operator = $feed['stripe_conditional_operator'];
$field = RGFormsModel::get_field($form, $feed['stripe_conditional_field_id']);
if (empty($field) || !$feed['stripe_conditional_enabled']) {
return true;
}
// if conditional is enabled, but the field is hidden, ignore conditional
$is_visible = !RGFormsModel::is_field_hidden($form, $field, array());
//TODO: if !is_visible then skip field_value stuff
$field_value = RGFormsModel::get_field_value($field, array());
$is_value_match = RGFormsModel::is_value_match($field_value, $feed['stripe_conditional_value'], $operator);
$do_stripe = $is_value_match && $is_visible;
return $do_stripe;
}
示例11: validate
public static function validate(&$form, $field_values)
{
$is_valid = true;
foreach ($form["fields"] as &$field) {
//ignore validation if field is hidden
if (RGFormsModel::is_field_hidden($form, $field, $field_values)) {
continue;
}
$value = RGFormsModel::get_field_value($field);
//display error message if field is marked as required and the submitted value is empty
if ($field["isRequired"] && self::is_empty($field)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a value.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
} else {
if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = is_array($value) ? __("This field requires an unique entry and the values you entered have been already been used", "gravityforms") : __(sprintf("This field requires an unique entry and '%s' has already been used", $value), "gravityforms");
$is_valid = false;
} else {
switch (RGFormsModel::get_input_type($field)) {
case "name":
if ($field["isRequired"] && $field["nameFormat"] != "simple") {
$first = $_POST["input_" . $field["id"] . "_3"];
$last = $_POST["input_" . $field["id"] . "_6"];
if (empty($first) || empty($last)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
break;
case "address":
if ($field["isRequired"]) {
$street = $_POST["input_" . $field["id"] . "_1"];
$city = $_POST["input_" . $field["id"] . "_3"];
$state = $_POST["input_" . $field["id"] . "_4"];
$zip = $_POST["input_" . $field["id"] . "_5"];
$country = $_POST["input_" . $field["id"] . "_6"];
if (empty($street) || empty($city) || empty($state) || empty($zip) || empty($country)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
break;
case "email":
if (!empty($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"];
$is_valid = false;
}
break;
case "number":
if (trim($value) != '' && !self::validate_range($field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
$is_valid = false;
}
break;
case "phone":
$regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
if ($field["phoneFormat"] == "standard" && !empty($value) && !preg_match($regex, $value)) {
$field["failed_validation"] = true;
if (!empty($field["errorMessage"])) {
$field["validation_message"] = $field["errorMessage"];
}
$is_valid = false;
}
break;
case "date":
if (is_array($value) && empty($value[0])) {
$value = null;
}
if (!empty($value)) {
$format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
$date = GFCommon::parse_date($value, $format);
if (empty($date) || !checkdate($date["month"], $date["day"], $date["year"])) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __(sprintf("Please enter a valid date in the format (%s).", $format == "mdy" ? "mm/dd/yyyy" : "dd/mm/yyyy"), "gravityforms") : $field["errorMessage"];
$is_valid = false;
}
}
break;
case "time":
//create variable values if time came in one field
if (!is_array($value) && !empty($value)) {
preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
$value = array();
$value[0] = $matches[1];
$value[1] = $matches[2];
}
$hour = $value[0];
$minute = $value[1];
if (empty($hour) && empty($minute)) {
break;
}
$is_valid_format = is_numeric($hour) && is_numeric($minute);
if (!$is_valid_format || $hour <= 0 || $hour > 12 || $minute < 0 || $minute >= 60) {
$field["failed_validation"] = true;
//.........这里部分代码省略.........
示例12: is_optin
public static function is_optin($form, $settings, $entry)
{
$config = $settings["meta"];
$field = RGFormsModel::get_field($form, $config["optin_field_id"]);
if (empty($field) || !$config["optin_enabled"]) {
return true;
}
$operator = isset($config["optin_operator"]) ? $config["optin_operator"] : "";
$field_value = RGFormsModel::get_field_value($field, array());
$is_value_match = RGFormsModel::is_value_match($field_value, $config["optin_value"], $operator);
$is_visible = !RGFormsModel::is_field_hidden($form, $field, array(), $entry);
$is_optin = $is_value_match && $is_visible;
return $is_optin;
}
示例13: get_issuer_id
public function get_issuer_id()
{
$fields = GFCommon::get_fields_by_type($this->form, array(Pronamic_WP_Pay_Extensions_GravityForms_IssuersField::TYPE));
foreach ($fields as $field) {
if (!RGFormsModel::is_field_hidden($this->form, $field, array())) {
return RGFormsModel::get_field_value($field);
}
}
}
示例14: save_incomplete_submission
public static function save_incomplete_submission($form, $entry, $field_values, $page_number, $files, $form_unique_id, $ip, $source_url, $resume_token = '')
{
if (!is_array($form['fields'])) {
return;
}
global $wpdb;
$table = self::get_incomplete_submissions_table_name();
$submitted_values = array();
foreach ($form['fields'] as $field) {
/* @var GF_Field $field */
if ($field->type == 'creditcard') {
continue;
}
$submitted_values[$field->id] = RGFormsModel::get_field_value($field, $field_values);
}
/**
* Allows the modification of submitted values before the incomplete submission is saved.
*
* @since 1.9
*
* @param array $submitted_values The submitted values
* @param array $form The Form object
*/
$submitted_values = apply_filters('gform_submission_values_pre_save', $submitted_values, $form);
$submission['submitted_values'] = $submitted_values;
$submission['partial_entry'] = $entry;
$submission['field_values'] = $field_values;
$submission['page_number'] = $page_number;
$submission['files'] = $files;
$submission['gform_unique_id'] = $form_unique_id;
// Issue a new token if no longer valid
if (!empty($resume_token)) {
$sql = $wpdb->prepare("SELECT COUNT(*) FROM {$table} WHERE uuid = %s", $resume_token);
$count = $wpdb->get_var($sql);
if ($count != 1) {
$resume_token = false;
}
}
if (empty($resume_token)) {
$resume_token = self::get_uuid();
$result = $wpdb->insert($table, array('uuid' => $resume_token, 'form_id' => $form['id'], 'date_created' => current_time('mysql', true), 'submission' => json_encode($submission), 'ip' => $ip, 'source_url' => $source_url), array('%s', '%d', '%s', '%s', '%s', '%s'));
} else {
$result = $wpdb->update($table, array('form_id' => $form['id'], 'date_created' => current_time('mysql', true), 'submission' => json_encode($submission), 'ip' => $ip, 'source_url' => $source_url), array('uuid' => $resume_token), array('%d', '%s', '%s', '%s', '%s'), array('%s'));
}
/**
* Fires after an incomplete submission is saved
*
* @since 1.9
*
* @param array $submission Contains the partially submitted entry, fields, values, and files.
* @param string $resume_token The unique resume token that was generated for this partial submission
* @param array $form The Form object
* @param array $entry The Entry object
*/
do_action('gform_incomplete_submission_post_save', $submission, $resume_token, $form, $entry);
return $result ? $resume_token : $result;
}
示例15: is_optin
public static function is_optin($form, $settings)
{
$config = $settings["meta"];
$operator = isset($config["optin_operator"]) ? $config["optin_operator"] : "";
$field = RGFormsModel::get_field($form, $config["optin_field_id"]);
$field_value = RGFormsModel::get_field_value($field, array());
if (empty($field) || !$config["optin_enabled"]) {
return true;
}
$is_value_match = RGFormsModel::is_value_match($field_value, rgar($config, "optin_value"), $operator);
return $is_value_match;
}