Changeset 17166
- Timestamp:
- 04/09/09 17:26:04 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfEasyFormPlugin/trunk/modules/sfEasyForm/templates/_formSchema.php
r16593 r17166 1 1 <?php 2 $field = sfOutputEscaper::unescape($field);3 2 4 /* global errors */ 5 if ($field instanceof sfForm) 6 { 7 echo $field->renderGlobalErrors(); 8 echo $field->renderHiddenFields(); 9 echo '<ul class="form-root">'; 10 } 11 else 12 { 13 echo $field->renderLabel(); 14 echo '<ul class="form-child">'; 15 } 3 $field = sfOutputEscaper::unescape($field); 16 4 17 /* custom renderer foreach childs */ 18 if (isset($decorators[$starPath=$path.'/*'])) 19 { 20 if ($decorators[$starPath]) 5 /* global errors */ 6 if ($field instanceof sfForm) 21 7 { 22 foreach ($field as $_name => $_field) 8 echo $field->renderGlobalErrors(); 9 echo '<ul class="form-root">'; 10 } 11 else 12 { 13 echo $field->renderLabel(); 14 echo '<ul class="form-child">'; 15 } 16 17 $hiddenBuffer = ''; 18 19 /* custom renderer foreach childs */ 20 if (isset($decorators[$starPath=$path.'/*'])) 21 { 22 if ($decorators[$starPath]) 23 23 { 24 include_partial($decorators[$starPath], array( 25 'fieldName' => $_name, 26 'field' => $_field, 27 'path' => $path.'/'.$_name, 28 'decorators' => $decorators, 29 'form' => $form, 30 )); 31 } 32 } 33 } 34 else 35 { 36 if (isset($decorators[$dirPath=$path.'/'])) 37 { 38 if ($decorators[$dirPath]) 39 { 40 include_partial($decorators[$dirPath], array( 41 'fieldName' => $fieldName, 42 'field' => $field, 43 'path' => $path, 44 'decorators' => $decorators, 45 'form' => $form, 46 )); 24 foreach ($field as $_name => $_field) 25 { 26 include_partial($decorators[$starPath], array( 27 'fieldName' => $_name, 28 'field' => $_field, 29 'path' => $path.'/'.$_name, 30 'decorators' => $decorators, 31 'form' => $form, 32 )); 33 } 47 34 } 48 35 } 49 36 else 50 37 { 51 foreach ($field as $_name => $_field)38 if (isset($decorators[$dirPath=$path.'/'])) 52 39 { 53 $_class = get_class($_field); 40 if ($decorators[$dirPath]) 41 { 42 include_partial($decorators[$dirPath], array( 43 'fieldName' => $fieldName, 44 'field' => $field, 45 'path' => $path, 46 'decorators' => $decorators, 47 'form' => $form, 48 )); 49 } 50 } 51 else 52 { 53 foreach ($field as $_name => $_field) 54 { 55 $_class = get_class($_field); 54 56 55 $_context = array(56 'fieldName' => $_name,57 'field' => $_field,58 'path' => $path.'/'.$_name,59 'decorators' => $decorators,60 'form' => $form,61 );57 $_context = array( 58 'fieldName' => $_name, 59 'field' => $_field, 60 'path' => $path.'/'.$_name, 61 'decorators' => $decorators, 62 'form' => $form, 63 ); 62 64 63 if (isset($decorators[$newPath=$path.'/'.$_name])) 64 { 65 if ($decorators[$newPath]) 65 if (isset($decorators[$newPath=$path.'/'.$_name])) 66 66 { 67 include_partial($decorators[$newPath], $_context); 68 } 69 } 70 else 71 { 72 if ($_class=='sfFormField') 73 { 74 if (!$_field->isHidden()) 67 if ($decorators[$newPath]) 75 68 { 76 echo '<li>'.$_field->renderError().$_field->renderLabel().$_field->render().'</li>';69 include_partial($decorators[$newPath], $_context); 77 70 } 78 }79 elseif ($_class=='sfFormFieldSchema')80 {81 echo '<li>'.get_partial(isset($decorators['@schema'])?$decorators['@schema']:'sfEasyForm/formSchema', $_context).'</li>';82 71 } 83 72 else 84 73 { 85 throw new Exception(sprintf('Rendering of «%s» is not implemented', $_class)); 74 if ($_class=='sfFormField') 75 { 76 if ($_field->isHidden()) 77 { 78 $hiddenBuffer .= $_field->render(); 79 } 80 else 81 { 82 echo '<li>'.$_field->renderError().$_field->renderLabel().$_field->render().'</li>'; 83 } 84 85 } 86 elseif ($_class=='sfFormFieldSchema') 87 { 88 echo '<li>'.get_partial(isset($decorators['@schema'])?$decorators['@schema']:'sfEasyForm/formSchema', $_context).'</li>'; 89 } 90 else 91 { 92 throw new Exception(sprintf('Rendering of «%s» is not implemented', $_class)); 93 } 86 94 } 87 95 } 88 96 } 89 97 } 90 } 98 91 99 ?></ul> 100 <?php echo $hiddenBuffer; ?>