I am created a Drupal module and added the form alter function:
MY_MODULE_form_alter(&$form, &$form_state, $form_id){
if(($form_id === 'commerce_checkout_flow_multistep_default') &&
($form['#step_id'] === 'order_information')){
$form['contact_information']['email']['#value'] = $email; // This is working
...
I also added this code:
$form['payment_information']['billing_information']['address'][0]['address']['given_name']['#value'] = $ime;
$form['payment_information']['billing_information']['address'][0]['address']['family_name']['#value'] = $prezime;
$form['payment_information']['billing_information']['address'][0]['address']['address_line1']['#value'] = $adresa;
$form['payment_information']['billing_information']['address'][0]['address']['postal_code']['#value'] = $ptt;
$form['payment_information']['billing_information']['address'][0]['address']['locality']['#value'] = $grad;
but this don't work for me. Any idea?
PHP does not expand simple quoted variables like '$grad'
. Don't quote variables unless it is really necessary and in this case use double quotes : "$grad"
. See PHP strings and variable expansion
Secondly, #value
is used to set values that cannot be edited by the user. Use #default_value
instead. See Drupal Form API
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.