<?php
$cnt = count($vars);
$i   = 1;
?>
<ul class="section-tabs">
<?php
foreach ($vars as $sKey => $section) {
    $class = "";
    if ($i == 1) {
        $class = "active";
    }
    ?>
    <li class="<?php echo esc_attr($class) ?> item-<?php echo esc_attr($sKey) ?>" data-class="section-<?php echo esc_attr($sKey) ?>"><?php echo esc_html($section["title"]); ?></li>
    <?php
$i++;
}
?>
</ul>
<?php

$i = 1;

foreach ($vars as $sKey => $section) {
    $class = "";
    if ($i == 1) {
        $class = "active";
    }
    ?>
    <div class="section section-<?php echo esc_attr($sKey) . " " . esc_attr($class); ?>">
        <div class="section-head">
            <div class="label"><?php echo esc_html($section["title"]); ?></div>
            <?php
            if (isset($section["tooltip"])) { ?>
                <div class="section-tooltip"><?php echo esc_html($section["tooltip"]); ?></div>
                <?php
            }
            ?>

        </div>
        <?php
        //Render fields
        $fields = $section["fields"];

        foreach ($fields as $key => $settings) {
            $isArray     = rad_array_value("array", rad_array_value("meta", $settings, array()), false);
            $val         = $this->rad_GetValue($key);
            $fieldRepeat = 1;

            //Convert the key so it become array type
            if ($isArray) {
                $key .= "[]";

                if (is_array($val)) {
                    $fieldRepeat = max(count($val), $fieldRepeat);
                }

            }

            for ($m = 0; $m < $fieldRepeat; $m++) {
                $value = is_array($val) ? rad_array_value($m, $val) : $val;

                echo "" . $this->GetField($key, $settings, array("val" => $value));
            }
        }
        ?>
    </div>
    <?php
    $i++;
}