現在の日付から始まる日付のリストを提供する List(Text) フィールドがあります。これらの日付は、ドロップダウン選択可能なオプションをユーザーに提供します。
プログラムで「日付のリスト」を提供する必要があるため、どの日であっても、システムは現在の日付を最初の日付として自動的に出力します。
問題は、許可された値のリストが PHP 形式をサポートしていないことです。
上記で概説したように、私のタスクをどのように達成できるか誰か教えてもらえますか?
Drupal Date モジュールを試してみてください。オプションがない場合は、プログラムで実行したい「日付要素を選択」せずに UI からフォームを作成できます。
その後、 form_id の「html ソース」をデバッグして、フォームの「id」を取得します。その後の使用hook_form_alter(&$form, & $form_state, $form_id)
function my_form_alter(&$form, & $form_state, $form_id) {
if ($form_id == 'MY_FORM_ID' ) {
$date_key_format = "m/d/y"; ;
$date_value_format = "F j, Y, g:i a";
$options = array(date($date_key_format) => date($date_value_format));
for ($i = 1; $i < 10; $i++ ) {
$options[date($date_key_format, strtotime("+$i days"))] = date($date_value_format, strtotime("+$i days"))
}
$form['date'] = array (
'#type' => 'select' ,
'#title' => 'Select Date' ,
'#options' => $options
'#weight' => 5 //based on where you want this element position to be
);
}
}
上記の select options では、現在の日付から始まり、現在の日付から 10 番目まで続きます。