public static function categoryParentSingleSelectEdit($categories, $parent_id, $category_id) {

        // STEP 1: Initiatize the html select tag
        $html = "";
        $html .=  '<select name="parent_id" id="parent_id" size="6" class="form-control">';

        $html .= '<option ';

        if ( $parent_id == 0) {
            $html .= ' selected="selected" ';
        }

        $html .= 'value="';
        $html .= 0;
        $html .= '">';
        $html .= 'No Parent Category';
        $html .= '</option>"';

        // STEP 2: Construct the <option></option> categories for ALL categories in the categories table
        foreach ($categories as $category) {

            if ($category->id == $category_id) {
                continue;
            }

            // If this tag is attached to the post, then SELECTED it
            $selected = "";

            if ( $category->id == $parent_id ) {
                $selected = ' selected="selected" ';
            } 

            $html .= '<option ';
            $html .= $selected;
            $html .= 'value="';
            $html .= $category->id;
            $html .= '">';
            $html .= $category->title;
            $html .= '</option>"';
        }
        $html .= '</select>';

        $html .= self::renderBootstrapMultiselectPlugin(count($categories));

        return $html;
    }
public static function categoryParentSingleSelectEdit($categories, $parent_id, $category_id) {

        // STEP 1: Initiatize the html select tag
        $html = "";
        $html .=  '<select name="parent_id" id="parent_id" size="6" class="form-control">';

        $html .= '<option ';

        if ( $parent_id == 0) {
            $html .= ' selected="selected" ';
        }

        $html .= 'value="';
        $html .= 0;
        $html .= '">';
        $html .= 'No Parent Category';
        $html .= '</option>"';

        // STEP 2: Construct the <option></option> categories for ALL categories in the categories table
        foreach ($categories as $category) {

            if ($category->id == $category_id) {
                continue;
            }

            // If this tag is attached to the post, then SELECTED it
            $selected = "";

            if ( $category->id == $parent_id ) {
                $selected = ' selected="selected" ';
            } 

            $html .= '<option ';
            $html .= $selected;
            $html .= 'value="';
            $html .= $category->id;
            $html .= '">';
            $html .= $category->title;
            $html .= '</option>"';
        }
        $html .= '</select>';

        $html .= self::renderBootstrapMultiselectPlugin(count($categories));

        return $html;
    }
public static function categoryParentSingleSelectEdit ( $ categories , $ parent_id , $ category_id ) { // STEP 1: Initiatize the html select tag $ html = "" ; $ html .= '<select name="parent_id" id="parent_id" size="6" class="form-control">' ; $ html .= '<option ' ; if ( $ parent_id == 0 ) { $ html .= ' selected="selected" ' ; } $ html .= 'value="' ; $ html .= 0 ; $ html .= '">' ; $ html .= 'No Parent Category' ; $ html .= '</option>"' ; // STEP 2: Construct the <option></option> categories for ALL categories in the categories table foreach ( $ categories as $ category ) { if ( $ category -> id == $ category_id ) { continue ; } // If this tag is attached to the post, then SELECTED it $ selected = "" ; if ( $ category -> id == $ parent_id ) { $ selected = ' selected="selected" ' ; } $ html .= '<option ' ; $ html .= $ selected ; $ html .= 'value="' ; $ html .= $ category -> id ; $ html .= '">' ; $ html .= $ category -> title ; $ html .= '</option>"' ; } $ html .= '</select>' ; $ html .= self :: renderBootstrapMultiselectPlugin ( count ( $ categories ) ) ; return $ html ; }
Create a multiple select drop down for tags
that have the existing tags for that post already selected

There is only one parent_id per category

@param  collection       $categories        All categories
@param  int              $parent id         category's parent id
@param  int              $category id       category's id
@return string
Create a multiple select drop down for tags that have the existing tags for that post already selected