rs19
rs19

Reputation: 667

concatenate @ to string in rails form

I have a rails form that takes in a slack username. In my view it concatenates a "@" to it as follows:

<div class="col-md-5ths col-xs-6"><h3>Slack </h3><h2> <%= "@#{@user.slack}"%></h2></div>

How would I have the edit form append the "@" so the user know's it's there?

Current form

<%= f.label :slack, "Slack username" %>
<%= f.text_field :slack, :maxlength => 30, class: 'form-control' %>

Upvotes: 3

Views: 216

Answers (1)

Said Kaldybaev
Said Kaldybaev

Reputation: 9962

placeholder disappears by design, I see that you're using Bootstrap, one way you could handle it is using input-group-addon to prepend or append elements

<div class="input-group">
    <span class="input-group-addon" id="basic-addon1">@</span>
    <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>

enter image description here

http://getbootstrap.com/components/#input-groups

Upvotes: 3

Related Questions