Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormGenerator is Back! (should close #717) #721

Merged
merged 2 commits into from Oct 24, 2011
Merged

FormGenerator is Back! (should close #717) #721

merged 2 commits into from Oct 24, 2011

Conversation

jcorcuera
Copy link
Contributor

It is based on the old FormGenerator and keeps the same configuration options.

@justinfrench
Copy link
Member

Excellent! When you say "based on", how much has it changed? Have you tested in both a Rails 3 and 3.1 app for completeness?

It is based on the old FormGenerator and keeps the same configuration options.
@jcorcuera
Copy link
Contributor Author

Yes it is tested in both Rails 3 and 3.1

The main changes compared with the old generator are:

  • Remove the --partial option, because it always generates a partial unless --copy option is set.
  • By default it uses the defined template engine on the application.
  • Add --template-engine option with support for ERB, HAML and SLIM. The old one only has the --haml option to render HAML template instead of ERB.
  • It keeps the --copy and --controller options.
  • About the model attributes:
    ** It takes the content columns and skips the columns defined in Formtastic::Helpers::InputsHelper::SKIPPED_COLUMNS like updated_at, created_at, etc.
    ** It only takes the belongs_to associations and skips if they are polymorphic because we can't guess which class to use for an automatically generated input.
  • It uses the templates already defined on /lib/generators/templates.

@justinfrench
Copy link
Member

Excellent work! So it's probably only the --template-engine option that needs to be documented. I can easily do that after I merge this in. Will do soon.

@jcorcuera
Copy link
Contributor Author

@justinfrench i just noticed something on the defined templates /lib/generators/templates it works ok for ERB but for HAML and SLIM it renders 4 spaces instead of two:

= semantic_form_for @post do |f|
  = f.inputs do
      = f.input :title    # 4 spaces
      = f.input :author # 4 spaces

  = f.buttons do
    = f.commit_button

I can fix them on this pull request too, what do you think?

@justinfrench
Copy link
Member

@jcorcuera yes please, make it as awesome as you can :)

@jcorcuera
Copy link
Contributor Author

Ok @justinfrench it's done!

One thing to keep in mind about the templates, they were already used by the formtastic:install generator so the users who run this generator (all users) have the wrong templates because they were copied to "lib/templates/#{engine}/scaffold/_form.html.#{engine}".

@justinfrench
Copy link
Member

@jcorcuera Urgh, I didn't realise we were copying stuff into the app. How is copy_scaffold_template called — can't see it in our code, so is Rails calling it? Any suggestions on making this less sucky?

@justinfrench
Copy link
Member

@jcorcuera The lib stuff is probably out of scope, so if you're happy with the work you've done, I'll merge it in.

@jcorcuera
Copy link
Contributor Author

Hi @justinfrench, The work about Form Generator is ok. The Install Generator is another issue, maybe we should open a new one.

@justinfrench
Copy link
Member

@jcorcuera please do add one, will merge this one in now, thanks.

justinfrench added a commit that referenced this pull request Oct 24, 2011
FormGenerator is Back! (should close #717)
@justinfrench justinfrench merged commit e767ce7 into formtastic:master Oct 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants