Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I'm using Imagefield with Filefield...
Where can I change the "Add another item" button text? I was searching through the files of both Filefield and Imagefield but could not find it.
Comment | File | Size | Author |
---|---|---|---|
#20 | cck_tweak_button.zip | 3.99 KB | Ken Hawkins |
add_another_item_button.jpg | 49.96 KB | OneTwoTait |
Comments
Comment #1
darksayings CreditAttribution: darksayings commentedI believe FileField lets CCK handle multiple values itself. So CCK sets that button's text, not FileField. I don't know if there is a simple way to change it, since it's set directly in a function content_multiple_value_form(), but somebody else might know more.
Comment #2
OneTwoTait CreditAttribution: OneTwoTait commentedThanks for the tip.
I found the text in cck/includes/content.node_form.inc and changed "item" to "photo" as I wanted.
I'm assuming that won't mess anything up....
Comment #3
darksayings CreditAttribution: darksayings commentedI don't see how it would interfere with anything directly (again, someone else might know more about that), but it could complicate upgrades. If CCK releases a new version and you want or need to upgrade, either you'll replace your modified file and need to change it again, or you won't replace it and could break something if the new release has changed something there.
Comment #4
jpetso CreditAttribution: jpetso commentedThe correct solution would be to form_alter() the node form and the JavaScript callback so that the form element's '#value' property is changed just for the specific field that you target. That would also remove upgrade issues. No, I'm not creating any example code, don't feel like searching and testing all the details.
Comment #5
dopry CreditAttribution: dopry commentedComment #6
udioron CreditAttribution: udioron commentedjpetso,
The form_alter part is not that complex:
However, can you give me a lead how do I force CCK to use my alter function when creating the AHAH output who could call my JS fix function after the AHAH call?
I couldn't find any usable callback place in ahah.js :-(
Thanks!
Comment #7
udioron CreditAttribution: udioron commentedI have moved this to the correct place, and chnaged this to a feature request.
Changing the text button should be easier - even if not really exposed via UI.
Please advice.
Comment #8
markus_petrux CreditAttribution: markus_petrux commentedTry form_alter against the $form_id == 'content_add_more_js'. ;-)
Comment #9
ppmax CreditAttribution: ppmax commentedI created a custom module to handle modifications to my node add form. I have a number of CCK fields in this form and it's easy to change the titles/values/etc using:
$form['field_foo']['#title'] = 'my new title';
This does not seem to work for me with the "Add another item" button. I tried:
$form['field_image_add_more']['#value'] = 'Add another image';
Shouldn't this work? Thanks--
pp
Comment #10
udioron CreditAttribution: udioron commentedThank you! it works!
:-)
Comment #11
udioron CreditAttribution: udioron commentedComment #12
ppmax CreditAttribution: ppmax commentedHi--
Im having trouble implementing this theme override. I have a custom module that themes my custom content type ("products") node form. in my module I have a custom function:
This isnt working--is it because I have a distinct case for content_add_more.js? Should this conditional be nested within the other case?
thanks much--
pp
Comment #13
lhernon CreditAttribution: lhernon commentedsubscribe
Comment #14
meecect CreditAttribution: meecect commentedFor your example you would need to put:
$form['field_image']['field_image_add_more']['#value'] = 'Add another image';
Comment #15
bastienson CreditAttribution: bastienson commentedOk with the first item but not with the second and more
(sorry for my english)
have you solutions?
thank
Bastien (france)
Comment #16
ppmax CreditAttribution: ppmax commented#15 is correct--this line of code only changes the button for the first instance of it. Clicking the button provides another button with the original text in the button...any tips?
thx
PP
Comment #17
jibize CreditAttribution: jibize commentedHi guys,
Just in case you're still looking for a solution, take a look at this great snippet: http://drupal.org/node/536842. Just need to create a very simple module and add the code to the .module file.
Comment #18
oknateI had more luck with this approach. I alter it in the original form and then again I alter it when the form element is recreated in the ahah callback.
Comment #19
Shiraz Dindar#18 suffers from the issue indicated in #15.
#17 works for me. I tweaked it as follows (and noted in the comments) to only modify the fields I wanted to modify, and to set the replacement text myself (rather than it just replacing the word "item" with the field title):
Comment #20
Ken Hawkins CreditAttribution: Ken Hawkins commentedI pilfered much of the contrib code and adapted it a bit to make a simple little module as I know many are intimidated by writing their own module.
The code is basically from http://drupal.org/node/536842 with inspiration from comment #19 so you can put in KISS refers to the your field name, ala:
Anyways, the code is attached and if anyone's feeling inspired all this module needs is a Drupal front end and it could probably be submitted as a project.
And, as always, don't use this on a live site before testing.
Comment #21
Ken Hawkins CreditAttribution: Ken Hawkins commentedSetting this to "needs review" to catch a few eyeballs.
Comment #22
bnice5000 CreditAttribution: bnice5000 commentedKen,
I am fairly new to Drupal, but I am very interested in this module. Is there any way I can help you test it?
--Brian
Comment #23
clintthayer CreditAttribution: clintthayer commented+1
Comment #24
koppie CreditAttribution: koppie commented@Ken: I love your module, it works perfectly. It would be awesome if you (or someone else?) could add a config screen where you could change the custom text in Drupal, rather than editing the .module file directly, but I love it as-is.
I'm marking this "tested by the community" because it is. I think this module is ready for inclusion in CCK. I'd also love to see it ported to D7.
Comment #25
Ken Hawkins CreditAttribution: Ken Hawkins commented@koppie: I'm still doing much learning in the realm of drupal module development — it will likely be a month or two before I'm feeling confident enough/have time to make this a full-fledged enough module to consider submitting it. That said, perhaps I should look into starting up my own sandbox module.
**UPDATE** Well that wash't too bad. The sandbox module lives at http://drupal.org/sandbox/khawkins98/1266386 and the dev code at https://github.com/khawkins98/cck_tweak_button
Comment #26
jay-dee-ess CreditAttribution: jay-dee-ess commentedFor D7 see:
http://drupal.org/project/custom_add_another
Comment #27
Royce Kimmons CreditAttribution: Royce Kimmons commentedYou can also do this in D7 by using hook_form_FORM_ID_alter in your module. Example:
Comment #28
Kris77 CreditAttribution: Kris77 commented#27 work for me in DRUPAL 7.
Custom_add_another module don't work with FieldCollection.
Thanks @Royce Kimmons