0

I have written a code in drupal that after hitting node edit a delete query will run and unselect the radio button to display an alert each time. The query is working fine but the radio button got unchecked after second time reload. I want to uncheck that just after user click "Edit"

function debtcc_manage_node_prepare($node)
{
  $nid = $node->nid;
  if ($nid != null) {
    //field_cache_clear();
    $query = db_delete('field_data_field_change_updation_date')
      ->condition('entity_id',$nid)->execute();
    field_cache_clear();

  }
}

How can I achieve that? Is there any function in drupal to refresh the page automatically or other way?

Souvik Das
  • 49
  • 2
  • 10

1 Answers1

0

Do a form alter and set default state for your field as uncheked:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {

if ($form_id == 'YOUR_FORM_ID' && $form['nid']['#value'] != NULL) {

$form['YOURFIELD'][LANGUAGE_NONE]['#default_value'] = 0;
}
}

Upon clicking on edit checkbox will be unchecked and you already taken care of the database.

Beyer
  • 301
  • 1
  • 9
  • Thank you. Its working fine. Although it can be done with custom field that I had tried earlier before this solution & that is also working :) – Souvik Das Jul 27 '18 at 10:50