0

using entityreference autocomplete widget (field-widget-entityreference-autocomplete) with entity connect I have the buttons "New content" and "Edit content".

How can I just rename them in "New" and "Edit" respectively ? These are coded in the value field of the input, hence I can't change them just with CSS..

I think I could do it on a form specific way using hook_form_alter, but I would like to apply it to any form where the widget appear.

I tried already hook_field_widget_form_alter(&$element, &$form_state, $context) but then I got lost, I am not sure it's the right place..

  • Entityreference doesn't offer content creation and modification by default, did you install entityconnect too? – Ben May 9 '15 at 11:25
  • @ben, yes.. I just edited the question to make it clear.. thank you – Antonello May 9 '15 at 11:30
1

In a form alter you can access those two buttons with something like:

$field_name = "field_test";
$form[$field_name][LANGUAGE_NONE][0]["add_entityconnect__".$field_name."_0_"]["#value"] = t("New");
$form[$field_name][LANGUAGE_NONE][0]["edit_entityconnect__".$field_name."_0_"]["#value"] = t("Edit");

Adapt the name, language and cardinality of the field accordingly.

You can use a basic hook_form_alter to affect all forms. The widget creation code is in entityconnect.form.inc and it can't be altered (no hooks, no variables).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.