當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PodsForm::default_value方法代碼示例

本文整理匯總了PHP中PodsForm::default_value方法的典型用法代碼示例。如果您正苦於以下問題:PHP PodsForm::default_value方法的具體用法?PHP PodsForm::default_value怎麽用?PHP PodsForm::default_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PodsForm的用法示例。


在下文中一共展示了PodsForm::default_value方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save_pod_item


//.........這裏部分代碼省略.........
                 }
             }
         }
         if ($allow_custom_fields && !empty($custom_fields)) {
             foreach ($custom_fields as $field) {
                 $custom_data[$field] = $params->data[$field];
             }
         }
         if ($pod['type'] === 'taxonomy' && isset($params->data) && !empty($params->data)) {
             $term_data = $params->data;
         }
         unset($params->data);
     }
     if (empty($params->id) && !in_array('created', $fields_active) && isset($fields['created']) && in_array($fields['created']['type'], array('date', 'datetime'))) {
         $fields['created']['value'] = current_time('mysql');
         $fields_active[] = 'created';
     }
     if (!in_array('modified', $fields_active) && isset($fields['modified']) && in_array($fields['modified']['type'], array('date', 'datetime'))) {
         $fields['modified']['value'] = current_time('mysql');
         $fields_active[] = 'modified';
     }
     if (in_array($pod['type'], array('pod', 'table')) && empty($params->id) && !empty($pod['pod_field_index']) && in_array($pod['pod_field_index'], $fields_active) && !in_array($pod['pod_field_slug'], $fields_active) && isset($fields[$pod['pod_field_slug']])) {
         $fields[$pod['pod_field_slug']]['value'] = '';
         // this will get picked up by slug pre_save method
         $fields_active[] = $pod['pod_field_slug'];
     }
     // Handle hidden fields
     if (empty($params->id)) {
         foreach ($fields as $field => $field_data) {
             if (in_array($field, $fields_active)) {
                 continue;
             }
             if (in_array($params->from, array('save', 'process_form')) || true === PodsForm::permission($fields[$field]['type'], $field, $fields[$field], $fields, $pod, $params->id, $params)) {
                 $value = PodsForm::default_value(pods_var_raw($field, 'post'), $field_data['type'], $field, pods_var_raw('options', $field_data, $field_data, null, true), $pod, $params->id);
                 if (null !== $value && '' !== $value && false !== $value) {
                     $fields[$field]['value'] = $value;
                     $fields_active[] = $field;
                 }
             }
         }
         // Set default field values for object fields
         if (!empty($object_fields)) {
             foreach ($object_fields as $field => $field_data) {
                 if (in_array($field, $fields_active)) {
                     continue;
                 } elseif (!isset($field_data['default']) || strlen($field_data['default']) < 1) {
                     continue;
                 }
                 $value = PodsForm::default_value(pods_var_raw($field, 'post'), $field_data['type'], $field, pods_var_raw('options', $field_data, $field_data, null, true), $pod, $params->id);
                 if (null !== $value && '' !== $value && false !== $value) {
                     $object_fields[$field]['value'] = $value;
                     $fields_active[] = $field;
                 }
             }
         }
         // Set default field values for Pod fields
         foreach ($fields as $field => $field_data) {
             if (in_array($field, $fields_active)) {
                 continue;
             } elseif (!isset($field_data['default']) || strlen($field_data['default']) < 1) {
                 continue;
             }
             $value = PodsForm::default_value(pods_var_raw($field, 'post'), $field_data['type'], $field, pods_var_raw('options', $field_data, $field_data, null, true), $pod, $params->id);
             if (null !== $value && '' !== $value && false !== $value) {
                 $fields[$field]['value'] = $value;
                 $fields_active[] = $field;
開發者ID:satokora,項目名稱:IT354Project,代碼行數:67,代碼來源:PodsAPI.php


注:本文中的PodsForm::default_value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。