Development

Changeset 9209

You must first sign up to be able to contribute.

Changeset 9209

Show
Ignore:
Timestamp:
05/23/08 09:48:41 (4 months ago)
Author:
FabianLange
Message:

1.0: added third mode for fillin xhtml, same as xml but without prolog (+test). fixes #3568

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/util/sfFillInForm.class.php

    r9189 r9209  
    4141  } 
    4242 
     43  /** 
     44   * fills in the values and returns HTML. This is a non validating tolerant mode. 
     45   * 
     46   * @return HTML with values filled in 
     47   */ 
    4348  public function fillInHtml($html, $formName, $formId, $values) 
    4449  { 
     
    6570  } 
    6671 
     72  /** 
     73   * fills in the values and returns XHTML. This is same as XML but stripts the XML Prolog. 
     74   * 
     75   * @return XHTML without prolog with values filled in 
     76   */ 
     77  public function fillInXhtml($xml, $formName, $formId, $values) 
     78  { 
     79    $xhtml = $this->fillInXml($xml, $formName, $formId, $values); 
     80    $prolog_regexp = '/^' . preg_quote('<?xml version="1.0"?>') . '\s*/'; 
     81    return preg_replace($prolog_regexp, '', $xhtml); 
     82  } 
     83 
     84  /** 
     85   * fills in the values and returns XHTML. It can only work correctly on validating XHTML. 
     86   * 
     87   * @return XHTML including XML prolog with values filled in 
     88   */ 
    6789  public function fillInXml($xml, $formName, $formId, $values) 
    6890  { 
  • branches/1.0/test/unit/util/sfFillInFormTest.php

    r8709 r9209  
    1212require_once($_test_dir.'/../lib/util/sfFillInForm.class.php'); 
    1313 
    14 $t = new lime_test(61, new lime_output_color()); 
     14$t = new lime_test(64, new lime_output_color()); 
    1515 
    1616$html = <<<EOF 
     
    264264$xml = $f->fillInXml($xml, 'form', null, array('foo' => 'bar')); 
    265265$t->like($xml, '#<input type="text" name="foo" value="bar"\s*/>#', '->fillInXml() outputs valid XML'); 
     266$t->like($xml, '#<\?xml version="1.0"\?>#',  '->fillInXml() outputs XML prolog'); 
     267 
     268// ->fillInXhtml() 
     269$xml = $f->fillInXhtml($xml, 'form', null, array('foo' => 'bar')); 
     270$t->like($xml, '#<input type="text" name="foo" value="bar"\s*/>#', '->fillInXml() outputs valid XML'); 
     271$t->unlike($xml, '#<\?xml version="1.0"\?>#',  '->fillInXhtml() does not output XML prolog'); 
    266272 
    267273// ->fillInHtml()