<div>
<select name="phone_country_code">
<option value="93" data-trunk-code="0">Afghanistan (+93)</option>
<option value="355" data-trunk-code="0">Albania (+355)</option>
<option value="213" data-trunk-code="0">Algeria (+213)</option>
...
<option value="263" data-trunk-code="0">Zimbabwe (+263)</option>
</select>
<input type="phone" name="phone" required="required">
</div>
Installation
Add this line to your application's Gemfile:
gem 'mobit'
or
gem 'mobit', :git => 'git://github.com/rubybeast/mobit.git'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mobit
Usage
Simple Helper 'rails_phone_tag'
<%= rails_phone_tag :phone, '', required: true %>
Form For 'form.rails_phone_field'
<%= form_for @example do |f|%>
<%= f.rails_phone_field :phone, required: true %>
<%= f.submit %>
<% end %>
Simple_Form_For 'form.rails_phone'
<%= simple_form_for @example do |f|%>
<%= f.input :phone, as: :country_phone, required: true %>
<%= f.submit %>
<% end %>
Formtastic 'form.country_phone'
<%= semantic_form_for @example do |form| %>
<%= form.country_phone :phone, required: true %>
<%= form.submit %>
<% end %>
Contributing
- Fork it ( https://github.com/[my-github-username]/mobit/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request