ambiguity in locales for labels, units, etc. #384

Closed
fringd opened this Issue Dec 7, 2011 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

fringd commented Dec 7, 2011

as things stand, there are some bugs and ambiguity in the locals for simpleform. the class names are clashing with default attribute labels.

imagine a property management app that manages deeds, titles, and documents. Now we might want to specify labels for the attributes of a "title" object:

en:
  simpleform:
    labels:
      title:
       property_name: ...
       execution_status: ...

but now my form for documents (which have a title attribute) looks like

document size: ______________
<#Hash 2l3kj2lk4jl24kj2l3kj...> : _______________

instead of

document size: ________________
title: ________________

as a workaround you can define 'simpleform.labels.document.title' to be 'title', but this shouldn't be needed.

is it possible to detect that you've recieved a hash instead of a string and ignore the value? this would at least fix the bug.

even better, it would be awesome to have the default attributes moved out of the top level (documents:, properties:, etc) and into a "default" subsection

i.e.

en:
  simple_form:
    labels:
      defaults:
        title: Please enter the Title
      document:
        title: Please enter the Document Title
      title:
        owner: ...
        property_address: ...

this would remove any ambiguity...

Owner

josevalim commented Dec 7, 2011

We could detect it is a hash, but that would be very slow. The best solution would be to move to a "defaults" setup. Maybe we should do it in time for Simple Form 2.0.

Contributor

fringd commented Dec 7, 2011

Okay, I'm working at the moment, but maybe I can look at putting
together a pull request after hours...

On Wed, Dec 7, 2011 at 2:20 PM, José Valim
reply@reply.github.com
wrote:

We could detect it is a hash, but that would be very slow. The best solution would be to move to a "defaults" setup. Maybe we should do it in time for Simple Form 2.0.


Reply to this email directly or view it on GitHub:
#384 (comment)

Collaborator

carlosantoniodasilva commented Dec 8, 2011

I agree it's time to change this structure, specially with new changes in 2.0. This is not the 1st time this issue arrives here.

@josevalim josevalim closed this in 259640e Dec 8, 2011

Contributor

fringd commented Dec 10, 2011

i have a perhaps more thorough fix... it lets you do defaults.edit, etc, allows lookup of defaults.reflection ( i think preventing that was a hack to deal with this problem ) and removes the test that that doesn't work. also updates the README..

Contributor

fringd commented Dec 10, 2011

a91613c

move default attribute translations out of root

Owner

josevalim commented Dec 10, 2011

Awesome, I like it. Could you please rebase it?

fringd added a commit to fringd/simple_form that referenced this issue Dec 10, 2011

move default attribute translations out of root
(#384)

- move simpleform.label.username to simpleform.label.defaults.username
- update README
- allow lookup of reflections on simpleform.label.defaults

Conflicts:

	lib/simple_form/inputs/base.rb
	test/components/label_test.rb
	test/form_builder/hint_test.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment