简体   繁体   中英

I want the update query for hook alter form for my created custom field

  Alter form in my account page i written:

  $form['field_first_name']['und']['0']['value']['#value'] = 'raju';

  function my_callback_function($form,$form_state)
   {
   global $user;
    $var = db_update('field_data_field_name')
     ->fields(array(
       'field_name_value' => $form_state['value']['field_name[und][0][value]'],  - > Not working -> store as NULL
       'field_name_value' => '', -> empty value
       'field_name_value' => 'raju', -> hard code stored
       ))
     ->condition('entity_id', $user->uid, '=')
     ->condition('entity_type', 'user', '=')
     ->execute();
     drupal_set_message('Updated sifhup');
     }

Default value is only storing in Database from API i fixed. But i like to override the value whenever need. So i want to know the form_state values from field in the database.

怀疑

A recommendation, install Devel and use dsm($form_state['values']); then inspect the array to find the correct array key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM