drupal modules - DRUPAL8 node alter form - options unset field not able to save data manually> -


i alter form(monthlytraining document)

error page

my code:

 function mymonthlytrainingdocument_form_node_form_alter(&$form, \drupal\core\form\formstateinterface $form_state, $form_id) {  //kint($form);  if($form['#form_id'] === 'node_monthly_technical_documents_form' ||   $form['#form_id'] === 'node_monthly_technical_documents_edit_form') {  $fas = good;   $form['title']['widget'][0]['value']['#default_value'] = $fas;  $form['field_document_name']['widget'][0]['value']['#default_value'] = 'nodealter';       unset($form['field_document_domain']['widget']['#options']);  // $fsad = array('yes'=>'yes','no'=>'no', 'ohter' => 'other');       $form['field_document_domain']['widget']['#options']= _load_chkstate(); $form['actions']['submit']['#submit'][] = 'mymonthlytraining_nodes_form_submit';        }     } 

function mymonthlytraining_nodes_form_submit($form, formstateinterface $form_state) {  drupal_set_message('i here');  } 

   function mymonthlytrainingdocument_node_presave(drupal\node\nodeinterface $node)     {   //$sstest = implode(',',array_filter($form_state->get('field_document_domain')->value));    $davids = $node->get('field_description')->value . '-' .  iadded;    $node->settitle($node->get('title')->value);   // $node->set('body', 'this body');    $node->set('field_document_name', $node->get('field_document_name')->value);     $node->set('field_description', $davids);    //    $node->set('field_document_domain', $sstest);            $node->set('field_document_domain',  $form_state->getvalue('field_document_domain')); 

}

  function _load_chkstate() {    $state = array('- select training name -');    $query = db_select("node", "a");    $query->distinct();    $query->fields("a", array('nid', 'type'));    $query->orderby("a.nid");    $result = $query->execute();      while($row = $result->fetchobject()){     $state[$row->nid] = $row->type;      }     //print_r($province);   return $state;      } 

i cannot able save option data of (document domain) field. kindly provide solution this.

other select option text field data, can able store value using function presave. alter submit (mymonthlytraining_nodes_form_submit) not usable presave me create node.

on save button click error message throw below [error: referenced entity (taxonomy_term: 64) not exist. ] waiting suggestions


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -