function buddyforms_afe_create_frontend_element($form, $form_args)
{
    global $buddyforms, $nonce;
    extract($form_args);
    $customfield_val = explode(',', $customfield_val);
    $post_type = $buddyforms[$form_slug]['post_type'];
    if (!$post_type) {
        return $form;
    }
    if (!isset($customfield['type'])) {
        return $form;
    }
    switch ($customfield['type']) {
        case 'tax-afe':
            $categories = get_categories(array('parent' => 0, 'hide_empty' => 0, 'taxonomy' => $customfield['taxonomy'], 'hierarchical' => false));
            $main_cats = false;
            if (is_array($categories)) {
                $main_cats['none'] = 'Select One';
                foreach ($categories as $key => $category) {
                    $main_cats[$category->term_taxonomy_id] = $category->name;
                }
            }
            $form->addElement(new Element_Select($customfield['name'], $customfield['slug'] . '-select', $main_cats, array('value' => $customfield_val, 'class' => 'tax_tax_tax', 'data-id' => $customfield['slug'], 'data-taxonomy' => $customfield['taxonomy'])));
            $form->addElement(new Element_HTML('<div id="taxtax_container">'));
            $terms = wp_get_post_terms($post_id, $customfield['taxonomy']);
            foreach ($terms as $key => $term) {
                $term_children = get_categories(array('parent' => $term->term_id, 'hide_empty' => 0, 'taxonomy' => $customfield['taxonomy'], 'hierarchical' => false));
                $term_children_array = false;
                if (is_array($term_children)) {
                    $term_children_array['none'] = 'Select One';
                    foreach ($term_children as $key => $term_child) {
                        $term_children_array[$term_child->term_taxonomy_id] = $term_child->name;
                    }
                }
                if (is_array($term_children_array) && count($term_children_array) > 1) {
                    $select = new Element_Select('', 'tax_tax_tax[sub][]', $term_children_array, array('class' => 'tax_tax_tax', 'value' => $customfield_val, 'data-id' => $customfield['slug'], 'data-taxonomy' => $customfield['taxonomy']));
                    ob_start();
                    $select->render();
                    $select = ob_get_clean();
                    $form->addElement(new Element_HTML($select));
                }
            }
            $form->addElement(new Element_HTML('</div>'));
            $form->addElement(new Element_Hidden($customfield['slug'], $form_args['customfield_val']));
            break;
    }
    return $form;
}