In a form, I have this:
        $status = new Zend_Form_Element_Select('status',
array('multiOptions' =>
            array(1 => 'Draft')));
        $status->addValidator('NotEmpty')
               ->setRequired(true)
               ->setLabel('Status')
               ->addDecorator('Label', array('tag' => 'div', 'id' =>
'status-label'))
               ->addDecorator('HtmlTag', array('tag' => 'div', 'id' =>
'status-container'));
        $this->addElement($status);

In the controller, I have this:
            $articleForm->getElement('status')->setMultiOptions(array(1 =>
'Draft', 3 => 'Pending', 2 => 'Published'));
            if ($this->_request->isPost()) {
                BC_Log::debug('status = "' .
$articleForm->getElement('status')->getValue() . '"');
                BC_Log::debug('status = "' .
$articleForm->getValue('status') . '"');
                if ($articleForm->isValid($_POST)) {
                    $values = $articleForm->getValues();
                    if ($values['status'] == 2 && $article->status <> 2) {
$firstPublish = true; }
                    $article = $mdlArticle->updateArticle($values);

The setMultiOptions() works.
The $articleForm->getValues() after the isValid works.
$values['status'] is properly set, and the conditional works, etc.

I'm trying to *add* some logic in between the isPost() and the
isValid($_POST), which is why I've stuck debug statements there. Both
attempts return nothing. (Actually, they return: status = "") I've tried
swapping out 'status' for other elements, like 'title', and that also gives
me nothing. It appears as if getValue() *always* returns nothing.

Do I have to do something else before getValue() will work? Do I have to get
*all* the values, when I only need to check a single one?

-- Phillip Winn -- http://blogcritics.org/ -- 214/402-9466 --

Reply via email to