Changeset 1387
- Timestamp:
- 05/25/06 17:24:49 (3 years ago)
- Files:
-
- trunk/lib/filter/sfFillInFormFilter.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/filter/sfFillInFormFilter.class.php
r1218 r1387 44 44 } 45 45 46 $skip_fields = $this->getParameter('skip_fields', array()); 47 48 $exclude_types = $this->getParameter('exclude_types', array('hidden', 'password')); 49 $check_types = $this->getParameter('check_types', array('text', 'checkbox', 'radio', 'password', 'hidden')); 50 $types = array_diff($check_types, $exclude_types); 51 $query = 'descendant::input[@name and (not(@type)'; 52 foreach ($types as $type) 53 { 54 $query .= ' or @type="'.$type.'"'; 55 } 56 $query .= ')] | descendant::textarea[@name] | descendant::select[@name]'; 57 46 58 // find our form 47 59 $xpath_query = $this->getParameter('name') ? '//form[@name="'.$this->getParameter('name').'"]' : '//form'; 48 60 if ($form = $xpath->query($xpath_query)->item(0)) 49 61 { 50 foreach($xpath->query( 'descendant::input[@name and (not(@type) or @type="text" or @type="checkbox" or @type="radio")] | descendant::textarea[@name] | descendant::select[@name]', $form) as $element)62 foreach($xpath->query($query, $form) as $element) 51 63 { 64 // skip fields specified in the 'skip_fields' attribute 65 if ($request->hasParameter($element->getAttribute('name')) && in_array($element->getAttribute('name'), $skip_fields)) 66 { 67 continue; 68 } 69 52 70 if ($element->nodeName == 'input') 53 71 { 54 if (!$element->hasAttribute('type') || $element->getAttribute('type') == 'text') 55 { 56 // text input 57 $element->removeAttribute('value'); 58 if ($request->hasParameter($element->getAttribute('name'))) 59 { 60 $element->setAttribute('value', $this->espaceRequestParameter($request, $element->getAttribute('name'))); 61 } 62 } 63 else if ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio') 72 if ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio') 64 73 { 65 74 // checkbox and radio … … 69 78 { 70 79 $element->setAttribute('checked', 'checked'); 80 } 81 } 82 else 83 { 84 // text input 85 $element->removeAttribute('value'); 86 if ($request->hasParameter($element->getAttribute('name'))) 87 { 88 $element->setAttribute('value', $this->espaceRequestParameter($request, $element->getAttribute('name'))); 71 89 } 72 90 }

