Development

Changeset 17166

You must first sign up to be able to contribute.

Changeset 17166

Show
Ignore:
Timestamp:
04/09/09 17:26:04 (4 years ago)
Author:
hartym
Message:

[sfEasyFormPlugin] fixed rendering of hidden fields

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfEasyFormPlugin/trunk/modules/sfEasyForm/templates/_formSchema.php

    r16593 r17166  
    11<?php 
    2 $field = sfOutputEscaper::unescape($field); 
    32 
    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); 
    164 
    17 /* custom renderer foreach childs */ 
    18 if (isset($decorators[$starPath=$path.'/*'])) 
    19 
    20   if ($decorators[$starPath]) 
     5  /* global errors */ 
     6  if ($field instanceof sfForm) 
    217  { 
    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]) 
    2323    { 
    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      } 
    4734    } 
    4835  } 
    4936  else 
    5037  { 
    51     foreach ($field as $_name => $_field
     38    if (isset($decorators[$dirPath=$path.'/'])
    5239    { 
    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); 
    5456 
    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        ); 
    6264 
    63       if (isset($decorators[$newPath=$path.'/'.$_name])) 
    64       { 
    65         if ($decorators[$newPath]) 
     65        if (isset($decorators[$newPath=$path.'/'.$_name])) 
    6666        { 
    67           include_partial($decorators[$newPath], $_context); 
    68         } 
    69       } 
    70       else 
    71       { 
    72         if ($_class=='sfFormField') 
    73         { 
    74           if (!$_field->isHidden()) 
     67          if ($decorators[$newPath]) 
    7568          { 
    76             echo '<li>'.$_field->renderError().$_field->renderLabel().$_field->render().'</li>'
     69            include_partial($decorators[$newPath], $_context)
    7770          } 
    78         } 
    79         elseif ($_class=='sfFormFieldSchema') 
    80         { 
    81           echo '<li>'.get_partial(isset($decorators['@schema'])?$decorators['@schema']:'sfEasyForm/formSchema', $_context).'</li>'; 
    8271        } 
    8372        else 
    8473        { 
    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          } 
    8694        } 
    8795      } 
    8896    } 
    8997  } 
    90 
     98 
    9199?></ul> 
     100<?php echo $hiddenBuffer; ?>