function testCleanValueIsReplacedBySuccessfulValidationWithMultipleFilterApplied() { $filter1 = new T_Test_Filter_Suffix('1st'); $filter2 = new T_Test_Filter_Suffix('2nd'); $hidden1 = new T_Form_Hidden('alias', 'value'); $hidden1->attachFilter($filter1)->attachFilter($filter2); $hidden2 = new T_Form_Hidden('alias', 'replace'); $hidden2->attachFilter($filter1)->attachFilter($filter2); $src = array($hidden2->getFieldname() => $hidden2->getFieldValue(), $hidden2->getChecksumFieldname() => $hidden2->getChecksumFieldValue()); $cage = new T_Cage_Array($src); $this->assertSame($hidden1, $hidden1->validate($cage)); $this->assertTrue($hidden1->isValid()); $this->assertTrue($hidden1->isPresent()); $this->assertFalse($hidden1->getError()); $this->assertSame('replace', $hidden1->getValue()); }
/** * Initialise the form to display the current step. * * @return void */ protected function init() { $cur = current($this->steps); if (!$cur) { return; } // parse prev/next steps $steps = $this->steps; $prev = false; $next = false; $found = false; foreach ($steps as $s) { if (!$found && $s === $cur) { $found = true; continue; } if (!$found) { $prev = $s; } if ($found && false == $next) { $next = $s; } } // setup forward label if ($next) { $label = 'Next: ' . $next->getLabel(); } else { $label = $this->getLabel(); } if (isset($this->action['forward'])) { $this->action['forward']->setLabel($label); } else { $forward = new T_Form_Button('forward', $label); $this->addAction($forward); } // *always* setup prev action (needed to detect prev actions) // // NB: The prev action is always setup and validated internally. It // is hidden in external getActions() calls by the is_prev_action // flag. This is necessary to detect prev action when a salted form // is validated. if ($this->is_prev_action = (bool) $prev) { $label = 'Back to ' . $prev->getLabel(); } else { $label = 'Back'; } if (isset($this->action['prev'])) { $this->action['prev']->setLabel($label); } else { $back = new T_Form_Button('prev', $label); $this->addAction($back); } // save history for other form steps form $data = new T_Form_Export(); $child = $this->steps; // leave original pointer intact foreach ($child as $f) { if ($f === $cur) { continue; } if ($f->isPresent()) { $f->accept($data); } } if ($history = $this->search('history')) { $history->setValue($data->getData()); } else { $field = new T_Form_Hidden('history', $data->getData()); $field->attachFilter(new T_Filter_ToUrlQuery()); $this->addChild($field); } // set current seek point if ($seek = $this->search('seek')) { $seek->setValue(key($this->steps)); } else { $field = new T_Form_Hidden('seek', key($this->steps)); $this->addChild($field); } }