-
Notifications
You must be signed in to change notification settings - Fork 2
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
repeatable_attr_input's simple_form_input_args[:label] option should be respected by add_another_text method #162
Comments
I'm not completely following where else it would get it from -- can't you already pass in an arg? Or no, there's no arg? I18n or an arg you pass in to |
Sorry to confuse! Basically, this code:
Where the field's label is "Display Note" (my element.label value), but the add another link value doesn't use that same label value. Instead it looks to I18n to find a match, and misses, ultimately rendering "Add another Gbl displaynote sm" kithe/app/simple_form_enhancements/kithe/repeatable_input_generator.rb Lines 214 to 222 in 56a65a9
Would prefer it to render "Add another Display Note" |
OH I see your title now, I wans't paying enough attention. OK, I think it sounds like a bug? |
Not so much a bug, but an oversight? Also, I18n would work great for everyone, except me pulling fields out of a database table. |
Oh wait, you are just passing it in as I don't think attr_json paying attention to what are essentially private simple_form_input_args is the right move necessarily.... hmm. Looking at the args to the method... I wonder if it needs a new arg. Not sure. |
If you pass in a field label, the add another link should use that same label. This isn't an attr_json issue, but an issue with the cocoon(-ish) repeatable element rendering code. |
OK! Thanks for bringing this up @ewlarson! I honestly have some other stuff I'm bogged down in at the moment, if you want to do a PR that would be awesome, although I might end up having Ideas about it. I'm still cautious about "reaching into" the arguments at While I'm a bit bogged down now, I might have more time in a couple weeks to look at it myself, have a zoom conversation/code share with you about it, or whatever. Thank you! |
Thanks for the comment! Yeah, I just think the field label and the repeatable field link text should be the same (do you have a case where that's not true?). Would definitely enjoy chatting some more about how we're using Kithe. For example, pulling our AttrJson attributes from a database table works well enough, but it also requires us to reload the application (and sidekiq) when our schema changes -- not ideal, but manageable, and not unlike say solr config changes. |
That seems fine.
Yes. I am aware of "dynamic attributes" as a use case -- someone on attr_json github issues just expressed it too. But honestly have not come up with any good solution for it -- I didn't realize you were doing it, and actually wouldn't have been confident it would have worked at all! I'm not really sure how to achieve it with the design goals of "as much like ordinary ActiveRecord attributes as possible", since ordinary ActiveRecord attributes have a lot of assumptions baked in that they will be class level, and the way ruby works that makes it hard to change them on the fly dynamically. So I'm not totally sure if attr_json is really suitable... although am interested that you have made it work anyway! But I'd love to hear more some time. |
It would be nice if
repeatable_attr_input
kept this potential label arg in mind when ultimately generating theadd_another_text
value. Otherwise, you end up with a nice label and a funny "Add another Gbl displaynote sm" link:I know you can add these field strings into a I18n file, but I specifically don't want to have to do that. I'm pulling all of my form fields, field types, labels, html_attributes, etc. from an ActiveRecord model:
https://github.com/geobtaa/geomg/blob/feature/attribute-model/db/schema.rb#L238-L264
Hoping to find time this week or next for a little PR to support this...
The text was updated successfully, but these errors were encountered: