acf_field_select::render_field_settings() public ACF 3.6
Create extra options for your field. This is rendered when editing a field. The value of $field['name'] can be used (like bellow) to save extra data to the $field
{} Это метод класса: acf_field_select{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$acf_field_select = new acf_field_select(); $acf_field_select->render_field_settings( $field );
- an($field -) (обязательный)
- array holding all the field's data
Список изменений
С версии 3.6 | Введена. |
Код acf_field_select::render_field_settings() acf field select::render field settings ACF 5.9.1
function render_field_settings( $field ) {
// encode choices (convert from array)
$field['choices'] = acf_encode_choices($field['choices']);
$field['default_value'] = acf_encode_choices($field['default_value'], false);
// choices
acf_render_field_setting( $field, array(
'label' => __('Choices','acf'),
'instructions' => __('Enter each choice on a new line.','acf') . '<br /><br />' . __('For more control, you may specify both a value and label like this:','acf'). '<br /><br />' . __('red : Red','acf'),
'name' => 'choices',
'type' => 'textarea',
));
// default_value
acf_render_field_setting( $field, array(
'label' => __('Default Value','acf'),
'instructions' => __('Enter each default value on a new line','acf'),
'name' => 'default_value',
'type' => 'textarea',
));
// allow_null
acf_render_field_setting( $field, array(
'label' => __('Allow Null?','acf'),
'instructions' => '',
'name' => 'allow_null',
'type' => 'true_false',
'ui' => 1,
));
// multiple
acf_render_field_setting( $field, array(
'label' => __('Select multiple values?','acf'),
'instructions' => '',
'name' => 'multiple',
'type' => 'true_false',
'ui' => 1,
));
// ui
acf_render_field_setting( $field, array(
'label' => __('Stylised UI','acf'),
'instructions' => '',
'name' => 'ui',
'type' => 'true_false',
'ui' => 1,
));
// ajax
acf_render_field_setting( $field, array(
'label' => __('Use AJAX to lazy load choices?','acf'),
'instructions' => '',
'name' => 'ajax',
'type' => 'true_false',
'ui' => 1,
'conditions' => array(
'field' => 'ui',
'operator' => '==',
'value' => 1
)
));
// return_format
acf_render_field_setting( $field, array(
'label' => __('Return Format','acf'),
'instructions' => __('Specify the value returned','acf'),
'type' => 'select',
'name' => 'return_format',
'choices' => array(
'value' => __('Value','acf'),
'label' => __('Label','acf'),
'array' => __('Both (Array)','acf')
)
));
}