/**
 * Get chart type as array
 *
 * @return array
 */
function erp_ac_get_all_chart_types_array()
{
    $classes = erp_ac_get_chart_classes();
    $all_types = erp_ac_get_all_chart_types();
    $types = [];
    foreach ($all_types as $type) {
        $types[$type->class_id][$type->id] = $type->name;
    }
    return $types;
}
<ol class="erp-form-fields">

    <li class="erp-form-field row-account-type-id">
        <label for="account_type_id"><?php 
_e('Account Type', 'erp-accounting');
?>
</label>

        <?php 
$custom_attr = isset($item->id) ? ['disabled' => 'disabled'] : [];
$classes = erp_ac_get_chart_classes();
$all_types = erp_ac_get_all_chart_types_array();
$selected = isset($item->type_id) ? $item->type_id : 0;
?>
        <select name="account_type_id" id="account_type_id" <?php 
echo isset($item->id) ? 'disabled="disabled"' : '';
?>
>
            <?php 
foreach ($all_types as $class_id => $types) {
    ?>
                <optgroup label="<?php 
    echo esc_attr($classes[$class_id]);
    ?>
">
                    <?php 
    foreach ($types as $type_id => $type) {
        ?>
                        <option value="<?php 
        echo $type_id;
        ?>