本文整理匯總了PHP中GF_Field::get_value_save_entry方法的典型用法代碼示例。如果您正苦於以下問題:PHP GF_Field::get_value_save_entry方法的具體用法?PHP GF_Field::get_value_save_entry怎麽用?PHP GF_Field::get_value_save_entry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GF_Field
的用法示例。
在下文中一共展示了GF_Field::get_value_save_entry方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepare_value
/**
* Prepare the value before saving it to the lead.
*
* @param mixed $form
* @param GF_Field $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
*
* @return mixed
*/
public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
{
$value = $field->get_value_save_entry($value, $form, $input_name, $lead_id, $lead);
// special format for Post Category fields
if ($field->type == 'post_category') {
$full_values = array();
if (!is_array($value)) {
$value = explode(',', $value);
}
foreach ($value as $cat_id) {
$cat = get_term($cat_id, 'category');
$full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ':' . $cat_id : '';
}
$value = implode(',', $full_values);
}
//do not save price fields with blank price
if ($field->enablePrice) {
$ary = explode('|', $value);
$label = count($ary) > 0 ? $ary[0] : '';
$price = count($ary) > 1 ? $ary[1] : '';
$is_empty = strlen(trim($price)) <= 0;
if ($is_empty) {
$value = '';
}
}
return $value;
}