2015-02-04 3 views
0

Forms API의 양식 컨트롤에 ID가 있습니까? (예를 들어) $ 양식 [ 'ID'] [ 'myphoto_button'] 위의 샘플 내 버튼의 ID를 식별 할 수Drupal 7 양식 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; 
} 

이 매우 간단 초보자의 질문에 대한 죄송하지만 방법 : 아래 내 샘플 코드는?

+0

. com/questions/146357/identify-form-control-id-in-drupal-7-forms-api) – Clive

답변

0

#attributes 속성은 요소의 html 속성을 설정하는 데 사용됩니다. (같은 이드, 클래스, 스타일, onclick, 등)

나는 당신이 onclick 처리기를 바인딩하는 데 사용하는 것을 볼 수 있습니다. 그래서, 당신의 버튼 ID를 제공하기 위해 주문 : //drupal.stackexchange : 나는 [교차 게시 드루팔 답변에] (HTTPS 되었기 때문에 오프 주제로이 질문을 닫으 투표 해요

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