패널에 모듈 양식을 포함하려고하는데 drupal_get_form()을 사용하여 시도했지만 올바르게 사용하고 있는지 확신 할 수 없습니다.drupal questions - 다른 모듈에서 양식을 인쇄하는 방법?
유기 그룹 모듈에는 og_broadcast_form을 렌더링하는 함수가 있습니다. og.module에 page_callback 내에서라고 :
// Broadcast tab on group node.
$items['node/%node/broadcast'] = array(
'title' => 'Broadcast',
'page callback' => 'drupal_get_form',
'page arguments' => array('og_broadcast_form', 1),
'access callback' => 'og_broadcast_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'file' => 'og.pages.inc',
'weight' => 7
);
그리고 og.pages.inc에서
이 기능은 다음과 같습니다 :function og_broadcast_form($form_state, $node) {
drupal_set_title(t('Send message to %group', array('%group' => $node->title)));
if (!empty($form_state['post'])) {
drupal_set_message(t('Your message will be sent to all members of this group.'));
}
$form['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#size' => 70,
'#maxlength' => 250,
'#description' => t('Enter a subject for your message.'),
'#required' => TRUE,
);
$form['body'] = array(
'#type' => 'textarea',
'#title' => t('Body'),
'#rows' => 5,
'#cols' => 90,
'#description' => t('Enter a body for your message.'),
'#required' => TRUE
);
$form['send'] = array('#type' => 'submit', '#value' => t('Send message'));
$form['gid'] = array('#type' => 'value', '#value' => $node->nid);
return $form;
}
나는 drupal_get_form의 변화의 숫자를 시도했습니다
print drupal_get_form('og_broadcast_form', NULL, arg(1)); //where arg 1 is the node id from the url
print drupal_get_form('og_broadcast_form');
print drupal_get_form('og_broadcast_form', &$form_state, arg(1));
print drupal_get_form('og_broadcast_form', $n); //where $n is node_load(arg(1));
print drupal_get_form('og_broadcast_form', &$form_state, $n);
기타 등등 ... 내가 여기에서하려고하는 것을 성취 할 수있는 방법이 있습니까?
고마워요,하지만 그걸 시도해 보았습니다 ... 제가 목록에 두 번째로 있는데 양식을 전혀 렌더링하지 않았습니까? – Dashiell0415
그건 맞지 않아요. 'drupal_get_form()'은 둘 이상의 인수를 허용합니다. 매개 변수에 대한 설명을 보려면 "... ... 추가 폼 인수는 고유 폼 생성자 함수를 포함하여 drupal_get_form()이 호출하는 함수에 전달됩니다. 예를 들어 node_edit 양식에서는 노드 객체가 여기에 전달되어야합니다 호출 될 때. ", 매개 변수'$ form_id'의 설명 바로 뒤에. – kiamlaluno
왜 arg 목록에 포함시키지 않겠습니까? 내게로 날아 갔다. – Kevin