Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
This is a generator gem for SimpleForm to make it works with MaterializeCSS.
There is an example application available on Heroku that demonstrate various features of Materialize::Form. You can view here: http://materialize-form.herokuapp.com/. To see the Source Code
Haven't install SimpleForm and Materialize SASS? Please follow this instruction:
Add this line to your application's Gemfile:
gem 'simple_form'
gem 'materialize-sass'
$ bundle install
$ rails generate simple_form:install
Require Materialize javascripts in app/assets/javascripts/application.js:
//= require jquery
//= require materialize-sprockets
Import Materialize styles in app/assets/stylesheets/application.scss:
@import "materialize";
NOTE: If you have just generated a new Rails application, it may come with a .css
file instead. If this file exists, it will be served instead of Sass, so remove it.
$ rm app/assets/stylesheets/application.css
Add this line to your application's Gemfile:
gem 'materialize-form'
Run the bundler and restart your server to make the files available through the pipeline and run the generator
$ bundle install
$ rails generate simple_form:materialize:install
Import Materialize Form javascript in app/assets/javascripts/application.js
:
//= require materialize-form
To start using Materialize Form you just have to use the helper it provides:
= simple_form_for @user do |f|
.row
= f.input :first_name, wrapper_html: { class: 'm6 s12' }
= f.input :last_name, wrapper_html: { class: 'm6 s12' }
= f.button :submit
= f.association :country, include_blank: 'What are your country?', wrapper_html: { class: 'm6 s12' }
File input will be generated automatically if the type of the field is attachment.
= f.input :avatar, wrapper_html: { class: 'm6 s12' }
Date picker will be generated automatically if the type of the field is date.
= f.input :dob, wrapper_html: { class: 'm6 s12' }
= f.association :hobbies, as: :check_boxes, wrapper_html: { class: 'm6 s12' }
= f.association :hobbies, include_blank: 'What are your hobbies?', wrapper_html: { class: 'm6 s12' }
= f.input :featured, wrapper_html: { class: 'm6 s12' }
= f.input :featured, wrapper: :materialize_boolean, wrapper_html: { class: 'm6 s12 ' }
= f.input :featured, as: :radio_buttons, wrapper_html: { class: 'm6 s12' }
In app/assets/javascripts/application.js
:
$(document).on('nested:fieldAdded', function(event){
window.materializeForm.init()
})
In app/assets/javascripts/application.js
:
$(document).on('turbolinks:load', function() {
window.materializeForm.init()
})
= simple_nested_form_for @category do |category_form|
.row
= category_form.input :title, wrapper_html: { class: 'm6 s12' }
= category_form.input :picture, wrapper_html: { class: 'm6 s12' }
#articles.row
= category_form.simple_fields_for :articles do |article_form|
.col.s12.m6
.row
= article_form.input :title, wrapper_html: { class: 'm6 s12'' }
= article_form.input :picture, wrapper_html: { class: 'm6 s12'' }
.row
= article_form.input :content, wrapper_html: { class: 's12' }
.right-align
= category_form.link_to_add "Add an article", :articles, class: 'btn', data: {target: "#articles"}
= category_form.button :submit
FAQs
Unknown package
We found that materialize-form demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.