Zend_Dojoを見てみましょう。これには、探しているものに近い要素が含まれている可能性があります。
具体的には、dijit.form.TimeTextBox、おそらくdijit.Calendarで、週末の日付の選択を無効にすることができます。または、dijit.form.selectZend_Form
は、Zend_Translate
平日を入れることができる拡張選択ボックスです。ユーザーの言語に簡単に翻訳できます。
同じことを行うためのjQueryウィジェットがたくさん利用できると確信しています。その方法をとった場合、必要に応じて緊密に結合するためにもう少し作業を行うZend_Form
必要がありますが、独自のデコレータと要素を作成することもできます。
Zend Framework リファレンス ガイドには、Dojo フォーム要素のTimeTextBox、DateTextBox、およびCombo/Select Boxesに関するいくつかの基本的な例があります。
これらの豊富な UI 要素を使用するのはやり過ぎかもしれません。その場合、要素を事前に入力して目的を達成するための簡単な方法は、値の配列 (曜日または時間) を返すヘルパー メソッドを作成することです。に簡単にフィードできますZend_Form_Element_Select::setMultiOptions()
。
例えば
public function getWeekdays()
{
$locale = new Zend_Locale('en_US'); // or get from registry
$days = Zend_Locale::getTranslationList('Days', $locale);
return $days['format']['wide'];
}
public function getTimes($options = array())
{
$start = null; // time to start
$end = null; // time to end
$increment = 900; // increment in seconds
$format = Zend_Date::TIME_SHORT; // date/time format
if (is_array($options)) {
if (isset($options['start']) && $options['start'] instanceof Zend_Date) {
$start = $options['start'];
}
if (isset($options['end']) && $options['end'] instanceof Zend_Date) {
$end = $options['end'];
}
if (isset($options['increment']) && is_int($options['increment']) && (int)$options['increment'] > 0) {
$increment = (int)$options['increment'];
}
if (isset($options['format']) && is_string($options['format'])) {
$format = $options['format'];
}
}
if ($start == null) {
$start = new Zend_Date('00:00:00', Zend_Date::TIME_LONG);
}
if ($end == null) {
$end = new Zend_Date('23:59:00', Zend_Date::TIME_LONG);
}
$times = array();
$time = new Zend_Date($start);
while($time < $end) { // TODO: check $end > $time
$times[] = $time->toString($format);
$time->add($increment, Zend_Date::SECOND);
}
return $times;
}
それらを呼び出す:
$opts = array('start' => new Zend_Date('07:00:00', Zend_Date::TIME_LONG),
'end' => new Zend_Date('20:00:00', Zend_Date::TIME_LONG),
'increment' => 3600);
$element->setMultiOptions($form->getTimes($opts));
$element2->setMultiOptions($form->getWeekdays());