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

Override text of "Remove" button from has_many form builder for specified resource #5283

Closed
newton10471 opened this issue Dec 11, 2017 · 8 comments · Fixed by #6523
Closed

Comments

@newton10471
Copy link

newton10471 commented Dec 11, 2017

There doesn't seem to be a straightforward way to change the text of the "Remove" button (to, in my case, something like "Hide") in the has_many form builder, .i.e., f.has_many, on a single page/model and not site-wide. I just want to confirm that is the case. If so, was there a specific reason this was left out? I can submit a PR to make it changeable if that helps.

@varyonic
Copy link
Contributor

Seems localized to me?

template.link_to I18n.t('active_admin.has_many_remove'), "#", class: 'button has_many_remove'

@newton10471
Copy link
Author

newton10471 commented Dec 12, 2017

Hi @varyonic, that allows for site-wide changes, right? I want to make a change to a single page / model. Is there a way to do that that I'm missing? Sorry for not being specific about that in my OP.

@varyonic
Copy link
Contributor

varyonic commented Dec 12, 2017

For a single model, eg. Offer, see if this works:

en:
  active_admin:
    resources:
      offer:
        has_many_remove: 'Remove Offer'

My guess is it won't, and the fix is to add localizer logic to form_builder like in Resource::ActionItems.

@newton10471
Copy link
Author

newton10471 commented Dec 12, 2017

This works for site-wide if I change config/locales/en.yml:

en:
  active_admin:
    has_many_remove: 'Hide'

but I tried what you suggested above for two different models and it doesn't seem to like it :(.

@newton10471
Copy link
Author

I'm using activeadmin 1.0.0.pre1, by the way. Not sure if that makes a difference?

@varyonic varyonic changed the title change text of "Remove" button from has_many form builder? Override text of "Remove" button from has_many form builder for specified resource Dec 12, 2017
@varyonic
Copy link
Contributor

varyonic commented Dec 12, 2017

Right, so further work is needed to make has_many remove button customizable in same way as action items. I don't think it was deliberately left out, just missed/forgotten/deferred, feel free to work on it.

@tooooooooomy
Copy link
Contributor

tooooooooomy commented Sep 16, 2018

@varyonic
I investigated this issue and found that FormBuilder becomes to depend on Resource to implement this feature(I guess it means FormBuilder depends on Application), but I wonder it is a correct approach or not.

I'd appreciate I could listen to any opinion if you have.

@littleforest
Copy link
Contributor

Hi, I'd like to work on this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants