ACF\Pro\Fields\FlexibleContent
Layout::render_as_table
Renders a layout as a table.
Метод класса: Layout{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_as_table();
Список изменений
| С версии 6.5 | Введена. |
Код Layout::render_as_table() Layout::render as table ACF 6.8.8
<?php
private function render_as_table() {
$sub_fields = $this->layout['sub_fields'];
?>
<table class="acf-table">
<thead>
<tr>
<?php
foreach ( $sub_fields as $sub_field ) {
// Set prefix to generate correct "for" attribute on <label>.
$sub_field['prefix'] = $this->prefix;
// Prepare field (allow sub fields to be removed).
$sub_field = acf_prepare_field( $sub_field );
if ( ! $sub_field ) {
continue;
}
$th_attrs = array(
'class' => 'acf-th',
'data-name' => $sub_field['_name'],
'data-type' => $sub_field['type'],
'data-key' => $sub_field['key'],
);
if ( $sub_field['wrapper']['width'] ) {
$th_attrs['data-width'] = $sub_field['wrapper']['width'];
$th_attrs['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
}
echo '<th ' . acf_esc_attrs( $th_attrs ) . '>';
acf_render_field_label( $sub_field );
acf_render_field_instructions( $sub_field );
echo '</th>';
}
?>
</tr>
</thead>
<tbody>
<tr><?php $this->sub_fields(); ?></tr>
</tbody>
</table>
<?php
}