コード例 #1
0
    function createForm()
    {
        $f = new Am_Form();
        $f->addHidden('s')->setValue($this->getFiltered('s'));
        $f->addHidden('e')->setValue($this->getParam('e'));
        $g = $f->addGroup('newsletter', array('id' => 'newsletter-group'))->setLabel(___('Untick checkbox to cancel subscription'));
        $g->setSeparator("<br />\n");
        $ids = $this->view->guest->getLists();
        foreach ($this->lists as $l) {
            $title = $l->title;
            if ($l->desc) {
                $title .= " - " . $l->desc;
            }
            $el = $g->addCheckbox($l->pk())->setContent($title);
            if (in_array($l->list_id, $ids) && !$this->_request->isPost()) {
                $el->setAttribute('checked');
            }
            // checked by default
        }
        if (count($this->lists) > 1) {
            $f->addCheckbox('unsubscribe')->setLabel(___('Cancel all Subscriptions'));
            $f->addScript()->setScript(<<<CUT
jQuery(document).ready(function(\$) {
    \$("input#unsubscribe-0").change(function(){
        \$("#row-newsletter-group").toggle(!this.checked);
    });
});
CUT
);
        }
        $f->addSubmit('do', array('value' => ___('Change Subscription')));
        return $f;
    }