Skip to content

Make argument `value` optional in form tags helpers #7059

wants to merge 1 commit into from

4 participants

jalkoby commented Jul 15, 2012

Often I need to build form(sign in or feedback form) with inputs which dont have value. But also I need specify custom style to it. So I use text_field_tag method in which second argument value and third options. But I dont need set value, so I put blank string or nil. As we know sending nil to method not good ruby practice, so I change it to more flexible way

   text_field_tag 'field', :class => 'custom css'

# is equal to

   text_field_tag 'field', nil, :class => 'custom css'

Also changed password field, email field, textarea and etc

jakedev commented Jul 15, 2012

So I normally have this issue too, but removing the nils in commits becomes an error.

jalkoby commented Jul 18, 2012

put changes into single commit

Ruby on Rails member

I didn't like this change. Right now the API is very clear and with this change it will be more confusing.

cc @josevalim

Ruby on Rails member

Agreed with @rafaelfranca

jalkoby commented Jul 21, 2012

maybe next time

@jalkoby jalkoby closed this Jul 21, 2012
Ruby on Rails member

@jalkoby I agree with you about the nil being a smell but right now, changing the API will confuse the people. I'm in favor of a better API to views helpers but we will need a lot of discussion.

Maybe in a next mayor release...

Thank you so much for your contribution. We really appreciate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.