Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Trouble with custom input mappings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Reid  
View profile  
 More options Feb 2 2011, 10:38 am
From: Reid <reid.gille...@gmail.com>
Date: Wed, 2 Feb 2011 07:38:41 -0800 (PST)
Local: Wed, Feb 2 2011 10:38 am
Subject: Trouble with custom input mappings
I apologize if I've just missed something completely obvious. My app
uses optimistic locking via the :lock_version attribute. I have been
including this in all my forms as <%= f.input :lock_version %> which
obviously displays as an integer field. I know that I can just
append :as => :hidden but I'd like to make this DRY and set up a
custom input mapping.

In my simple_form.rb initializer I have added the line:
config.input_mappings = { /lock_version/ => :hidden }

This is not working. I have tested it with different fields and
different input types and none of it appears to work. Did I miss
something totally obvious?

Thanks for your help.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile  
 More options Feb 2 2011, 10:59 am
From: Rafael Mendonça França <rafael....@gmail.com>
Date: Wed, 2 Feb 2011 12:59:38 -0300
Local: Wed, Feb 2 2011 10:59 am
Subject: Re: Trouble with custom input mappings

Sorry but, did you restart the server?

I tried to reproduce it, but I did not succeed. I used this test:

swap SimpleForm, :input_mappings => { /lock_version/ => :hidden } do
  with_form_for @user, :lock_version
  assert_no_select 'form input#user_lock_version.integer'
  assert_select 'form input#user_lock_version.hidden'
end

And it works.

Rafael Mendonça França
Twitter: http://twitter.com/rafaelfranca
Blog: www.rafaelfranca.com.br


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Feb 2 2011, 11:04 am
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Wed, 2 Feb 2011 14:04:14 -0200
Local: Wed, Feb 2 2011 11:04 am
Subject: Re: Trouble with custom input mappings

Also, this feature is only available in SimpleForm 1.3 and master, which
version are you using?
If you are using an older version, I'd recommend you to use from master
instead of 1.3, there should be a new release soon.

On Wed, Feb 2, 2011 at 1:59 PM, Rafael Mendonça França <rafael....@gmail.com

--
At.
Carlos A. da Silva

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reid  
View profile  
 More options Feb 2 2011, 11:59 pm
From: Reid <reid.gille...@gmail.com>
Date: Wed, 2 Feb 2011 20:59:45 -0800 (PST)
Local: Wed, Feb 2 2011 11:59 pm
Subject: Re: Trouble with custom input mappings
The server has been restarted a few times since I added the mappings
but just to be sure restarted it again with no luck. I was using
SimpleForm 1.3 but switched to master per your suggestion... still no
luck.

Incase I am really messing this up, here is my form:
<%= simple_form_for @project do |f| %>
        ...
        <%= f.input :lock_version %>
        <%= f.button :submit %>
<% end %>

The attribute is called lock_version and my config line is as above.
Thank you for your assistance... I know an easy fix would be to use
the :as => :hidden to each instance but the custom mapping would be so
much cleaner.

-Reid

On Feb 2, 10:04 am, Carlos Antonio da Silva


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile  
 More options Feb 3 2011, 10:37 am
From: Rafael Mendonça França <rafael....@gmail.com>
Date: Thu, 3 Feb 2011 12:37:37 -0300
Local: Thurs, Feb 3 2011 10:37 am
Subject: Re: Trouble with custom input mappings

I found the bug. In the actual code base the custom mappings only works for
string attributes, as you can see here:

https://github.com/plataformatec/simple_form/blob/master/lib/simple_f...

I will provide a patch to work with all types.

Rafael Mendonça França
Twitter: http://twitter.com/rafaelfranca
Blog: www.rafaelfranca.com.br


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Feb 3 2011, 10:39 am
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Thu, 3 Feb 2011 13:39:23 -0200
Local: Thurs, Feb 3 2011 10:39 am
Subject: Re: Trouble with custom input mappings

Right, good catch. Thanks.

On Thu, Feb 3, 2011 at 1:37 PM, Rafael Mendonça França <rafael....@gmail.com

--
At.
Carlos A. da Silva

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile  
 More options Feb 3 2011, 11:12 am
From: Rafael Mendonça França <rafael....@gmail.com>
Date: Thu, 3 Feb 2011 13:12:14 -0300
Local: Thurs, Feb 3 2011 11:12 am
Subject: Re: Trouble with custom input mappings

This pull request fixes the bug. Please test the commit and report back if
it works.

https://github.com/plataformatec/simple_form/pull/180

<https://github.com/plataformatec/simple_form/pull/180>Rafael Mendonça
França
Twitter: http://twitter.com/rafaelfranca
Blog: www.rafaelfranca.com.br

On Thu, Feb 3, 2011 at 12:39 PM, Carlos Antonio da Silva <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Feb 3 2011, 11:26 am
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Thu, 3 Feb 2011 14:26:09 -0200
Local: Thurs, Feb 3 2011 11:26 am
Subject: Re: Trouble with custom input mappings

Sounds good.
Just a question for discussion: do you think custom types should have high
or lower precedence over the default input types?

On Thu, Feb 3, 2011 at 2:12 PM, Rafael Mendonça França <rafael....@gmail.com

--
At.
Carlos A. da Silva

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile  
 More options Feb 3 2011, 11:33 am
From: Rafael Mendonça França <rafael....@gmail.com>
Date: Thu, 3 Feb 2011 13:33:58 -0300
Local: Thurs, Feb 3 2011 11:33 am
Subject: Re: Trouble with custom input mappings

I think that custom types should have high precedence.

If I'm setting a custom mapping for a attribute I really need it to use my
custom mapping.

This was the case that I saw more people using. Like the Reid.

Rafael Mendonça França
Twitter: http://twitter.com/rafaelfranca
Blog: www.rafaelfranca.com.br

On Thu, Feb 3, 2011 at 1:26 PM, Carlos Antonio da Silva <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Feb 3 2011, 1:22 pm
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Thu, 3 Feb 2011 16:22:27 -0200
Local: Thurs, Feb 3 2011 1:22 pm
Subject: Re: Trouble with custom input mappings

I agree they should have higher precedence, hopefully it won't lead to any
sort of confusion. Just wanted to put that under discussion =D.
I'll apply your patch later, just waiting Reid feedback. Thanks mate.

On Thu, Feb 3, 2011 at 2:33 PM, Rafael Mendonça França <rafael....@gmail.com

--
At.
Carlos A. da Silva

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reid  
View profile   Translate to Translated (View Original)
 More options Feb 3 2011, 8:14 pm
From: Reid <reid.gille...@gmail.com>
Date: Thu, 3 Feb 2011 17:14:59 -0800 (PST)
Local: Thurs, Feb 3 2011 8:14 pm
Subject: Re: Trouble with custom input mappings
Works perfectly! Thank you both so much.

On Feb 3, 12:22 pm, Carlos Antonio da Silva


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Feb 3 2011, 8:35 pm
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Thu, 3 Feb 2011 23:35:09 -0200
Local: Thurs, Feb 3 2011 8:35 pm
Subject: Re: Trouble with custom input mappings

Applied in master branch.
Thanks guys.

--
At.
Carlos A. da Silva

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »