/**
  * Executes this filter.
  *
  * @param sfFilterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     // execute next filter
     $filterChain->execute();
     $response = $this->context->getResponse();
     $request = $this->context->getRequest();
     $fillInForm = new sfFillInForm();
     // converters
     foreach ($this->getParameter('converters', array()) as $functionName => $fields) {
         $fillInForm->addConverter($functionName, $fields);
     }
     // skip fields
     $fillInForm->setSkipFields((array) $this->getParameter('skip_fields', array()));
     // types
     $excludeTypes = (array) $this->getParameter('exclude_types', array('hidden', 'password'));
     $checkTypes = (array) $this->getParameter('check_types', array('text', 'checkbox', 'radio', 'password', 'hidden'));
     $fillInForm->setTypes(array_diff($checkTypes, $excludeTypes));
     // fill in
     $method = 'fillIn' . ucfirst(strtolower($this->getParameter('content_type', 'Html')));
     try {
         $content = $fillInForm->{$method}($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll());
         $response->setContent($content);
     } catch (sfException $e) {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array($e->getMessage(), 'priority' => sfLogger::ERR)));
         }
     }
 }
Example #2
0
    </form>
  </body>
</html>
EOF;
$xml = $f->fillInXml($xml, 'form', null, array('foo' => 'bar'));
$t->like($xml, '#<input type="text" name="foo" value="bar"\\s*/>#', '->fillInXml() outputs valid XML');
$t->like($xml, '#<option value="selected" selected="selected">#', '->fillInXml() outputs valid XML');
$t->like($xml, '#<\\?xml version="1.0"\\?>#', '->fillInXml() outputs XML prolog');
// ->fillInXhtml()
$xml = $f->fillInXhtml($xml, 'form', null, array('foo' => 'bar'));
$t->like($xml, '#<input type="text" name="foo" value="bar"\\s*/>#', '->fillInXhml() outputs valid XML');
$t->like($xml, '#<option value="selected" selected="selected">#', '->fillInXhml() outputs valid XML');
$t->unlike($xml, '#<\\?xml version="1.0"\\?>#', '->fillInXhtml() does not output XML prolog');
// ->fillInHtml()
$t->diag('->fillInHtml()');
$f = new sfFillInForm();
$xml = <<<EOF
<html>
  <body>
    <form action="#" method="post" name="form">
      <input type="text" name="foo">
      <select name="select">
        <option value="first">first</option>
        <option value="selected" selected="selected">selected</option>
        <option value="last">last</option>
      </select>
    </form>
  </body>
</html>
EOF;
$xml = $f->fillInHtml($xml, 'form', null, array('foo' => 'bar'));