在Drupal7表单API中标识表单控件id

在Drupal7表单API中标识表单控件id,drupal,drupal-7,form-api,Drupal,Drupal 7,Form Api,Forms API中的表单控件是否具有id?下面是我的示例代码: function myid_user_page_form(){ $form = array(); $form['id'] = array( '#type' => 'fieldset', '#title' => t('ID Information'), '#collapsible' => TRUE, '#collapsed' =&

Forms API中的表单控件是否具有id?下面是我的示例代码:

function myid_user_page_form(){  
    $form = array();
    $form['id'] = array(
        '#type' => 'fieldset',
        '#title' => t('ID Information'),
        '#collapsible' => TRUE, 
        '#collapsed' => FALSE,
    );  
    $form['id']['myphoto_button'] = array(
        '#type' => 'button', 
        '#value' => '...',
        '#attributes' => array(
        'onclick' => "myphoto_options();",),  
    );
    return $form;
 }
很抱歉,这是一个非常简单的初学者问题,但是如何在上面的示例中识别我的按钮id,例如$form['id']['myphoto\u button']?

该属性用于设置元素的html属性。比如,id,class,style,onclick等等

我可以看到您正在使用它绑定onclick处理程序。因此,为您的按钮提供一个id是非常必要的:

$form['id']['myphoto_button'] = array(
    '#type' => 'button', 
    '#value' => '...',
    '#attributes' => array(
        'onclick' => "myphoto_options();",
        'id'      => 'YOUR-BUTTON-ID',
    ),  
);

我投票决定把这个问题作为离题的问题来结束,因为它已经过时了