本文整理汇总了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;