1

I have an entity created with eck module, and when I want to delete an entity the message is :

Are you sure that you want to delete %id ?

I want to change this message to show me the title of the entity and not the id. I find where this is implemented, is in the code below in eck.entity.inc file located under the eck module folder:

function eck__entity__delete_form($form, &$form_state, $entity_type, $bundle, $id){
  $path = eck__entity_type__path();
    
  $entities = entity_load($entity_type->name, array($id));

  $form['entity'] =
      array(
        '#type' => 'value',
        '#value' => $entities[$id],
  );

  $form['entity_type'] =
      array(
        '#type' => 'value',
        '#value' => $entity_type,
  );

  $form['bundle'] =
      array(
        '#type' => 'value',
        '#value' => $bundle,
  );

  $form['submit_redirect'] =
  array(
    '#type' => 'value',
    '#value' => "{$path}/{$entity_type->name}/{$bundle->name}",
  );

  $message = t("Are you sure that you want to delete %id",
          array("%id" => $id));

  $caption = t("This action cannot be undone.");

  return confirm_form($form, $message, "{$path}/{$entity_type->name}", $caption, t('Delete'));
  
}

Is there a way to change this confirm message without changing the code of this module ? thanks in advance

1 Answer 1

1

You can use hook form alter to change a piece of the form, see this answer by Clive:

https://stackoverflow.com/questions/8111034/altering-title-on-drupal-node-delete-confirmation-form

2
  • In this case the name of the function should be : MYMODULE_form_entity_delete_confirm_alter ? because this is not a node entity but a custom entity! Mar 14, 2014 at 16:26
  • most likely. if you install the devel module in and in the code you have listed above add to the very top of the function (its 1st line) dpm($form_id, __FUNCTION__); you will see the form_id of this form and the function name calling the dpm notice to the page (this function).
    – tenken
    Mar 14, 2014 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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