22
April
I want to change select list value in my state field so we follow the step My content type is 'project' so we can get the form id as 'node_project_form' I have a feild 'state' in my content type so field machine name is 'field_state'
function MODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) { $dropdown_array = array('DL'=>'Delhi'); if ($form_id == 'node_project_form') { $form['field_state']['widget'] = array( '#type' => 'select', '#default_value' => 'DL', '#options' => $dropdown_array, ); } $form['actions']['submit']['#submit'][] = 'mynode_submit_handler'; } function mynode_submit_handler($form, FormStateInterface $form_state) { }
© 2023.ZedAngle. All Rights Reserved.