function acf_views_render_fields($post_id = 0, $fields, $el = 'div', $instruction = 'label') { // bail early if no fields if (empty($fields)) { return false; } // remove corrupt fields $fields = array_filter($fields); //Load all the values first foreach ($fields as &$ref_field) { // load value if ($ref_field['value'] === null) { $ref_field['value'] = acf_get_value($post_id, $ref_field); } } $hiding_fields = false; // loop through fields foreach ($fields as $field) { // load value if ($field['value'] === null) { $field['value'] = acf_get_value($post_id, $field); } // set prefix for correct post name (prefix + key) $field['prefix'] = 'acf'; // render $show_field = true; if (!empty($field['conditional_logic'])) { $show_field = ACF_Views_Conditional_Logic::show_field($field, $fields); } if ($field['type'] == 'tab') { if (!$show_field) { $hiding_fields = true; } else { $hiding_fields = false; } } if (!$hiding_fields) { if ($show_field) { if ($field['type'] == 'repeater') { $x = 1; } acf_views_render_field_wrap($field, $el, $instruction); } } } }
// prevent repeater field from creating multiple conditional logic items for each row if ($i !== 'acfcloneindex') { $sub_field['conditional_logic'] = 0; } // add value if (isset($value[$sub_field['key']])) { // this is a normal value $sub_field['value'] = $value[$sub_field['key']]; } elseif (isset($sub_field['default_value'])) { // no value, but this sub field has a default value $sub_field['value'] = $sub_field['default_value']; } // update prefix to allow for nested values $sub_field['prefix'] = "{$field['name']}[{$i}]"; // render input acf_views_render_field_wrap($sub_field, $el); } ?> <?php if ($layout['display'] == 'table') { ?> </tbody> </table> <?php } else { ?> </div> <?php } ?>