简体   繁体   中英

Can't set default value

Using drupal 7 I try to render only one field. Code:

$form = array();
$form['pager2'] = array(
    '#type' => 'select',
    '#title' => t('page'),
    '#options' => array('1'=>'1', '2'=>'2'), 
    '#default_value' => '2',
);
$page.=drupal_render($form);

Default value in any case is '1'. What i've done wrong?

Try out below code:

$form = array();
$form['pager2'] = array(
    '#type' => 'select',
    '#title' => t('page'),
    '#options' => array('1'=>'1', '2'=>'2'), 
    '#default_value' => '2',
);
return $form;

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