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

Add HTML5 input[type="time"] helper #5715

Merged
merged 1 commit into from
May 18, 2012
Merged

Add HTML5 input[type="time"] helper #5715

merged 1 commit into from
May 18, 2012

Conversation

soulim
Copy link
Contributor

@soulim soulim commented Apr 3, 2012

No description provided.

def render
options = @options.stringify_keys
options["value"] = @options.fetch("value") { value(object).try(:strftime, "%H:%M:%S") }
options["size"] = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set the "size" to nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca input[type="time"] doesn't have size attribute.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Got it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this nilling out our own default size, or silently dropping a user-provided size?

Better to raise an ArgumentError if the user provided a size, if we really don't want it.

But better yet, does it matter? Most browsers show time input as a text field and respect size, so why not allow it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, ok. I think we're doing it wrong elsewhere, too! Looks good for now though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These code was removing the size since we added a default value to it. Since we removed the code that add this default value we can remove these lines. I'm fixing it now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed in the other places. We can remove here now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca thank you. I removed this line too.

@steveklabnik
Copy link
Member

This no longer merges cleanly, and will need a rebase.

@soulim
Copy link
Contributor Author

soulim commented May 16, 2012

@steveklabnik done. Thank you!

@@ -646,6 +646,32 @@ def test_date_field_with_nil_value
assert_dom_equal(expected, date_field("post", "written_on"))
end

def test_time_field
expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="00:00:00.000" />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the value required? I think that if we don't have a value it should be blank.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca you are right, the value isn't required.
Time is not blank in this case, it is 00:00:00.000.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thank you.

@carlosgaldino carlosgaldino mentioned this pull request May 17, 2012
@soulim
Copy link
Contributor Author

soulim commented May 18, 2012

Guys, do you have any new feedback?

@rafaelfranca
Copy link
Member

Could you squash the commits. I'll ask to @jeremy to merge it.

@soulim
Copy link
Contributor Author

soulim commented May 18, 2012

@rafaelfranca done. It's just one commit now.

jeremy added a commit that referenced this pull request May 18, 2012
Add HTML5 input[type="time"] helper
@jeremy jeremy merged commit d8e8ab1 into rails:master May 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants