{"action":"created","issue":{"url":"https://api.github.com/repos/justinfrench/formtastic/issues/1211","repository_url":"https://api.github.com/repos/justinfrench/formtastic","labels_url":"https://api.github.com/repos/justinfrench/formtastic/issues/1211/labels{/name}","comments_url":"https://api.github.com/repos/justinfrench/formtastic/issues/1211/comments","events_url":"https://api.github.com/repos/justinfrench/formtastic/issues/1211/events","html_url":"https://github.com/justinfrench/formtastic/pull/1211","id":145441962,"number":1211,"title":"[experiment] Configurable mapping of columns to inputs","user":{"login":"mikz","id":154571,"avatar_url":"https://avatars.githubusercontent.com/u/154571?v=3","gravatar_id":"","url":"https://api.github.com/users/mikz","html_url":"https://github.com/mikz","followers_url":"https://api.github.com/users/mikz/followers","following_url":"https://api.github.com/users/mikz/following{/other_user}","gists_url":"https://api.github.com/users/mikz/gists{/gist_id}","starred_url":"https://api.github.com/users/mikz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikz/subscriptions","organizations_url":"https://api.github.com/users/mikz/orgs","repos_url":"https://api.github.com/users/mikz/repos","events_url":"https://api.github.com/users/mikz/events{/privacy}","received_events_url":"https://api.github.com/users/mikz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-03T01:36:16Z","updated_at":"2016-04-19T15:03:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/justinfrench/formtastic/pulls/1211","html_url":"https://github.com/justinfrench/formtastic/pull/1211","diff_url":"https://github.com/justinfrench/formtastic/pull/1211.diff","patch_url":"https://github.com/justinfrench/formtastic/pull/1211.patch"},"body":"This is a proof of concept to offer ability to configure column to input mapping per form builder.\r\n\r\nSome people want to map a column to different input type (#1165, #1143). Some people want a default (#1183). Some would like to have an override (#1187).\r\n\r\nproposed in https://github.com/justinfrench/formtastic/issues/1146#issuecomment-203114072\r\n\r\nI'd like to get some comments on this approach and verify it solves problems raised in #1146.\r\nI'm not saying I'm happy with this particular API, it is too early for that. But IMO the way is right.\r\n\r\n/cc @justinfrench @timoschilling @jclay\r\n\r\n## Examples\r\n\r\nI have not tried them. But they should work. The idea is to verify the API is ok for those use cases and then actually implement it and have a test coverage for those.\r\n\r\n### Adding inet (https://github.com/justinfrench/formtastic/issues/1146#issuecomment-127635091)\r\n\r\n```ruby\r\nstring_input = Formtastic::FormBuilder.input_mapping.add_input(:string)\r\nstring_input.match_type(:inet)\r\n```\r\n\r\n### Mapping Hstore to text (#1165)\r\n\r\n```ruby\r\ntext_input = Formtastic::FormBuilder.input_mapping.add_input(:text)\r\ntext_input.match_type(:hstore)\r\n```\r\n\r\n### Mapping color to string (#1143) (not implemented yet)\r\n\r\n```ruby\r\nstring_input = Formtastic::FormBuilder.input_mapping.prepend_input(:string)\r\nstring_input.match_column(/color/)\r\n```\r\n\r\n\r\n### Having global default (#1183) (should change)\r\n\r\n```\r\nstring_input = Formtastic::FormBuilder.input_mapping.add_input(:string)\r\nstring_input.match_type(nil)\r\n```\r\n\r\n### Having a name without a type (#1187)\r\n\r\n```\r\npassword_input = Formtastic::FormBuilder.input_mapping.add_input(:password)\r\npassword_input.match_type(nil)\r\npassword_input.match_column(/password/)\r\n```\r\n\r\n\r\n### TODO\r\n\r\n- [ ] figure out better way to handle defaults than `Input#match_type(nil)`\r\n- [ ] on form builder inheritance, the input mapping gets copied and possibly mutated"},"comment":{"url":"https://api.github.com/repos/justinfrench/formtastic/issues/comments/211967669","html_url":"https://github.com/justinfrench/formtastic/pull/1211#issuecomment-211967669","issue_url":"https://api.github.com/repos/justinfrench/formtastic/issues/1211","id":211967669,"user":{"login":"mikz","id":154571,"avatar_url":"https://avatars.githubusercontent.com/u/154571?v=3","gravatar_id":"","url":"https://api.github.com/users/mikz","html_url":"https://github.com/mikz","followers_url":"https://api.github.com/users/mikz/followers","following_url":"https://api.github.com/users/mikz/following{/other_user}","gists_url":"https://api.github.com/users/mikz/gists{/gist_id}","starred_url":"https://api.github.com/users/mikz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikz/subscriptions","organizations_url":"https://api.github.com/users/mikz/orgs","repos_url":"https://api.github.com/users/mikz/repos","events_url":"https://api.github.com/users/mikz/events{/privacy}","received_events_url":"https://api.github.com/users/mikz/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T15:03:06Z","updated_at":"2016-04-19T15:03:06Z","body":"@justinfrench awesome feedback! I have no idea how the ideal interface would look like, but maybe we can get there with some experimentation :) Will give it some time and try to come up with another experiment."}}