protected function _initConfigForm(Am_Form $form) { $period = $form->addSelect('period')->setLabel(___('Period'))->loadOptions(array_merge($this->getDi()->interval->getOptions(), array(self::PERIOD_EXACT => ___('Exact')))); $period_exact = self::PERIOD_EXACT; $script = <<<CUT \$(function(){ \$('select[name=period]').change(function(){ \$(this).closest('.am-form').find('input[name=start], input[name=stop]'). closest('div.row'). toggle(\$(this).val() == '{$period_exact}'); }).change(); }) CUT; $form->addScript()->setScript($script); $start = $form->addElement('Date', 'start')->setLabel(___('Start')); $start->addRule('required'); $stop = $form->addElement('Date', 'stop')->setLabel(___('End')); $stop->addRule('required'); $form->addRule('callback', 'Start Date cannot be later than the End Date', array($this, 'checkStopDate')); $quant = $form->addElement('Select', 'quant')->setLabel(___('Quantity')); $quant->addRule('required'); $quant->loadOptions($this->getQuantityOptions()); }