为什么我的表单提交时我的提交处理程序不被调用?以下函数是从页面模板中调用的...在引导模式窗口中...因此模式会在页面加载时加载。我有一种感觉,条件是与提交处理程序被调用相干涉,或者我没有返回什么东西?此代码位于表单的模块中。我正在使用默认的提交处理程序。Drupal表单提交处理程序不工作,但为什么?
function winner_modal_form_communication($node) {
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
我测试,看看它已经被张贴,否则两个日期是从外地减去因为它(在一次后负荷,然后一次)被调用两次。如果已经发布(因为这意味着他们填写了获胜表格),我会打印出确认信息。
// WINNING DATES
if (!empty($node->field_win_dates{'und'}{0}{'value'})) {
$winDatesString = $node->field_win_dates{'und'}{0}{'value'};
$winDatesArray = explode(", ", $winDatesString);
}
// TODAYS DATE
$todaysDatePST = date("Y-m-d H:i:s");
// EVENT DATES
$eventDateUTC = $node->field_date{'und'}{0}{'value'};
$eventDateObject = new DateTime($eventDateUTC, new DateTimeZone('UTC'));
$eventDateObject->setTimezone(new DateTimeZone('America/Los_Angeles'));
$eventDatePST = $eventDateObject->format('Y-m-d H:i:s');
我只是设置了一些变量...然后一些条件。
// EXPIRED EVENT
if ($todaysDatePST > $eventDatePST) {
print "Sorry, this event has expired.<br /><button type='button' class='btn btn-default' data-dismiss='modal'>Continue</button>";
}
// WINNER
else if (($todaysDatePST > $winDatesArray[0]) && (!empty($winDatesString))) {
print "You've just won<br />TWO FREE TICKETS<br />to see " . $node->title . "!";
$form = drupal_get_form('winner_modal_form');
print drupal_render($form);
unset($winDatesArray[0]);
$newWinningDatesString = implode(", ",$winDatesArray);
$node->field_win_dates{'und'}{0}{'value'} = $newWinningDatesString;
node_save($node);
}
// NO WINNER
else {
print "You didn't win tickets to " . $node->title. ", but you can still learn more by pressing the continue button.";
print "<br /><button type='button' class='btn btn-default' data-dismiss='modal'>Continue</button>";
}
}
// WINNER CONFIRMATION
else {
print "Thank you! This is the confirmation modal window. That's right, you were the winner!<br /><button type='button' class='btn btn-default' data-dismiss='modal'>Continue</button>";
}
}
如果我删除上述条件提交处理程序的作品。
function winner_modal_form_submit($form, &$form_state) {
dpm("It worked!");
}
我在做什么错?任何洞察力将不胜感激(我是编程新手)。
好吧,它更具可读性,但那不是。 – know1