mywebsos/carbon-field-extended-multiselect
Composer 安装命令:
composer require mywebsos/carbon-field-extended-multiselect
包简介
An extension for Carbon Fields that adds a Multiselect field with the ability to retrieve either the label, value, or key/value array.
README 文档
README
This extension adds a Multiselect field to the Carbon Fields library, with the added ability to retrieve either the label, value, or key/value array of the selected options.
Installation
To install the extension, you can use the following command:
composer require mywebsos/carbon-fields-extended-multiselect
Usage
To use the Extended Multiselect field in your Carbon Fields container, you can use the following code:
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make( 'post_meta', __( 'Extended Multiselect Field' ) )
->add_fields( array(
Field::make( 'extended_multiselect', 'extended_multiselect_field', __( 'Select options' ) )
->set_options( array(
'option_1' => 'Option 1',
'option_2' => 'Option 2',
'option_3' => 'Option 3',
) )
->return_format( 'array' ) // label, array or value ( default )
) );
You can retrieve the selected options using the following methods:
// Retrieve the label of the selected options
$value = carbon_get_post_meta( get_the_ID(), $field_name );
Note
Make sure to include the use statement of Carbon_Fields\Field at the top of your file.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-01-16