当前位置: 首页>>代码示例>>PHP>>正文


PHP PodsForm::options方法代码示例

本文整理汇总了PHP中PodsForm::options方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::options方法的具体用法?PHP PodsForm::options怎么用?PHP PodsForm::options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PodsForm的用法示例。


在下文中一共展示了PodsForm::options方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pods_cf_populate_options

/**
 * Pre-populate options for bound fields
 *
 * @since 1.0.0
 *
 * @param array $field Field config
 *
 * @return array Field config
 */
function pods_cf_populate_options($field)
{
    global $form;
    $processors = Caldera_Forms::get_processor_by_type('pods', $form);
    if (empty($processors)) {
        return $field;
    }
    foreach ($processors as $processor) {
        // is configured
        $fields = array();
        if (!empty($processor['config']['fields'])) {
            $fields = array_merge($fields, $processor['config']['fields']);
        }
        if (!empty($processor['config']['object_fields'])) {
            $fields = array_merge($fields, $processor['config']['object_fields']);
        }
        if ($bound_field = array_search($field['ID'], $fields)) {
            // now lets see if this is a pick field
            $pod = pods($processor['config']['pod'], null, false);
            $pod_field = $pod->fields($bound_field);
            if (!empty($pod_field['options']['required'])) {
                $field['required'] = 1;
            }
            if ($pod_field['type'] === 'pick') {
                $options = PodsForm::options($pod_field['type'], $pod_field);
                include_once PODS_DIR . 'classes/fields/pick.php';
                $fieldtype = new PodsField_Pick();
                $choices = $fieldtype->data($bound_field, null, $options, $pod);
                $field['config']['option'] = array();
                foreach ($choices as $choice_value => $choice_label) {
                    $field['config']['option'][] = array('value' => $choice_value, 'label' => $choice_label);
                }
            }
        }
    }
    return $field;
}
开发者ID:Giannisduke,项目名称:pods-caldera-forms,代码行数:46,代码来源:functions.php


注:本文中的PodsForm::options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。