Changeset 8707
- Timestamp:
- 05/01/08 12:07:36 (1 year ago)
- Files:
-
- branches/1.0/lib/util/sfFillInForm.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/lib/util/sfFillInForm.class.php
r8695 r8707 54 54 { 55 55 $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 56 if (strpos($xml,'<!DOCTYPE') === false) 57 { 58 $xml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '. 59 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'. 60 $xml; 61 } 56 62 @$dom->loadXML($xml); 57 63 … … 74 80 } 75 81 82 // find our form 83 if ($formName) 84 { 85 $xpath_query = '//'.$ns.'form[@name="'.$formName.'"]'; 86 } 87 elseif ($formId) 88 { 89 $xpath_query = '//'.$ns.'form[@id="'.$formId.'"]'; 90 } 91 else 92 { 93 $xpath_query = '//'.$ns.'form'; 94 } 95 96 $form = $xpath->query($xpath_query)->item(0); 97 if (!$form) 98 { 99 if (!$formName && !$formId) 100 { 101 throw new sfException('No form found in this page'); 102 } 103 else 104 { 105 throw new sfException(sprintf('The form "%s" cannot be found', $formName ? $formName : $formId)); 106 } 107 } 108 76 109 $query = 'descendant::'.$ns.'input[@name and (not(@type)'; 77 110 foreach ($this->types as $type) … … 80 113 } 81 114 $query .= ')] | descendant::'.$ns.'textarea[@name] | descendant::'.$ns.'select[@name]'; 82 83 // find our form84 if ($formName)85 {86 $xpath_query = '//'.$ns.'form[@name="'.$formName.'"]';87 }88 elseif ($formId)89 {90 $xpath_query = '//'.$ns.'form[@id="'.$formId.'"]';91 }92 else93 {94 $xpath_query = '//'.$ns.'form';95 }96 97 $form = $xpath->query($xpath_query)->item(0);98 if (!$form)99 {100 if (!$formName && !$formId)101 {102 throw new sfException('No form found in this page');103 }104 else105 {106 throw new sfException(sprintf('The form "%s" cannot be found', $formName ? $formName : $formId));107 }108 }109 115 110 116 foreach ($xpath->query($query, $form) as $element)

