README in josevalim-simple_form-0.1.1 vs README in josevalim-simple_form-0.2.0

- old
+ new

@@ -15,28 +15,31 @@ class ContactForm < SimpleForm subject "My Contact Form" recipients "your.email@your.domain.com" sender{|c| %{"#{c.name}" <#{c.email}>} } - attribute :name, :validate => true - attribute :email, :validate => /[^@]+@[^\.]+\.[\w\.\-]+/ - attribute :company_name - attribute :telephone - attribute :message, :validate => true - attribute :nickname, :captcha => true + attribute :name, :validate => true + attribute :email, :validate => /[^@]+@[^\.]+\.[\w\.\-]+/ + attribute :file, :attachment => true + + attribute :message + attribute :nickname, :captcha => true end Then you start a script/console and type: c = ContactForm.new(:name => 'José', :email => 'jose@email.com', :message => 'Cool!') c.deliver Check your inbox and the e-mail will be there, with the sent fields. -SimpleForm is tested and compatible with Rails 2.2.x and Rails 2.3.x. It also -supports I18n and error messages, just as an ActiveRecord model does. +SimpleForm also support attachments, I18n, error messages like in ActiveRecord +(so it works with custom FormBuilders) and can also send the user request information +in the contact mail. +It's tested and compatible with Rails 2.2.x and Rails 2.3.x. + Installation ------------ Install Simple Form is very easy. It is stored in GitHub, so just run the following: @@ -45,10 +48,29 @@ If you want it as plugin, just do: script/plugin install git://github.com/josevalim/simple_form.git +Request +------- + +SimpleForm makes easy to append user information to the contact mail. You just +have to do: + + class ContactForm < SimpleForm + append :remote_ip, :user_agent, :session + # ... + end + +And in your controller: + + @contact_form = ContactForm.new(params[:contact_form], request) + +And the remote ip, user agent and session will be sent in the e-mail in a +request information session. You can send to append any method that the +request object responds to. + API Overview ------------ == attributes(*attributes) @@ -59,10 +81,13 @@ * :validate - When true, validates the attributes can't be blank. When a regexp is given, check if the attribute matches is not blank and then if it matches the regexp. +* :attachment - When given, expects a file to be sent and attaches + it to the e-mail. Don't forget to set your form to multitype. + * :captcha - When true, validates the attributes must be blank. This is a simple way to avoid spam and the input should be hidden with CSS. Examples: @@ -107,32 +132,39 @@ == headers(hash) Additional headers to your e-mail. -== recipients(string_or_array) +== recipients(string_or_array_or_proc) -Who will receive the e-mail. Can be a string or array. +Who will receive the e-mail. Can be a string or array, or a proc that returns one of them. I18n ---- All models, attributes and messages in SimpleForm can be used with localized. Below is an I18n example file: simple_form: models: - contact_form: Formulário de contato + contact_form: "Your site contact form" attributes: - name: Nome - email: E-mail - company_name: Empresa - telephone: Telefone - message: Mensagem + email: "E-mail" + telephone: "Telephone number" + message: "Sent message" messages: - blank: "não pode ficar em branco" - invalid: "não é válido" - telephone: "deve haver oito dígitos" + blank: "can not be blank" + invalid: "is not valid" + telephone: "must have eight digits" + request: + title: "Technical information about the user" + remote_ip: "IP Address" + user_agent: "Browser" + +Contributors +------------ + +* "Andrew Timberlake":http://github.com/andrewtimberlake Bugs and Feedback ----------------- If you discover any bugs, please send an e-mail to jose.valim@gmail.com