acf_field_checkbox::render_field
Create the HTML interface for your field
Метод класса: acf_field_checkbox{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$acf_field_checkbox = new acf_field_checkbox(); $acf_field_checkbox->render_field( $field );
- $field(обязательный)
- .
Список изменений
| С версии 3.6 | Введена. |
Код acf_field_checkbox::render_field() acf field checkbox::render field ACF 6.4.2
function render_field( $field ) {
// reset vars
$this->_values = array();
$this->_all_checked = true;
// ensure array
$field['value'] = acf_get_array( $field['value'] );
$field['choices'] = acf_get_array( $field['choices'] );
// hiden input
acf_hidden_input( array( 'name' => $field['name'] ) );
// vars
$li = '';
$ul = array(
'class' => 'acf-checkbox-list',
);
// append to class
$ul['class'] .= ' ' . ( $field['layout'] == 'horizontal' ? 'acf-hl' : 'acf-bl' );
$ul['class'] .= ' ' . $field['class'];
// checkbox saves an array
$field['name'] .= '[]';
// choices
if ( ! empty( $field['choices'] ) ) {
// choices
$li .= $this->render_field_choices( $field );
// toggle
if ( $field['toggle'] ) {
$li = $this->render_field_toggle( $field ) . $li;
}
}
// custom
if ( $field['allow_custom'] ) {
$li .= $this->render_field_custom( $field );
}
// return
echo '<ul ' . acf_esc_attrs( $ul ) . '>' . "\n" . $li . '</ul>' . "\n"; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped by specific render methods above.
}