Support

Account

Home Forums General Issues Deleting spaces in field entrys (for IDs)

Solved

Deleting spaces in field entrys (for IDs)

  • i want to give the user the possibility to insert bootstrap tabs like here:

    http://getbootstrap.com/javascript/#tabs

    this is the part of the code where i get the “title” of the tabs, i use the title as the ID, too:

    while ( have_rows('tab_zeile') ) : the_row();
    // display a sub field values
    echo '<div role="tabpanel" class="tab-pane" id="'.get_sub_field("tab_titel").'">';
    the_sub_field('tab_inhalt');
    echo '</div>';

    the problem is that in the IDs (id=”‘.get_sub_field(“tab_titel”).'”) no SPACES are allowed, so it works with “Infoabouttomatos” but not with “Info about tomatos”. Any idea how to solve this problem? something like a … “slug”? 😀

  • okay did it with “str_replace”, just forgot that i used it some months ago, too:

    // display a sub field values
    echo '<div role="tabpanel" class="tab-pane" id="'.str_replace(' ', '', get_sub_field("tab_titel")).'">';		        the_sub_field('tab_inhalt');
    echo '</div>';
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Deleting spaces in field entrys (for IDs)’ is closed to new replies.