Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.47 KB | None | 0 0
  1. [?php
  2.  
  3. $widget = $form[$name]->getWidget();
  4. $widgetClass = get_class($widget);
  5. $use_attributes = $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes;
  6. if ($widgetClass == "sfWidgetFormDoctrineChoice"){
  7.   if ($form[$name]->getWidget()->getOption("multiple") === true){
  8.       $widgetClass .= " list-multiple";
  9.   }
  10. }
  11. $use_attributes["class"] = $widgetClass;
  12.  
  13. if ($widgetClass == "sfWidgetFormSchemaDecorator"){
  14.     $embedded = $form->getEmbeddedForm($name);
  15.  
  16.     if ($fieldsets = $embedded->getGroupedFields())
  17.     {
  18.         foreach ($fieldsets as $fieldset => $fields)
  19.         {
  20.         ?]
  21.             <fieldset class="form-fieldset" id="sf_fieldset_[?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($fieldset)) ?]">
  22.         [?php if ('NONE' != $fieldset): ?]
  23.              <h2>[?php echo __($fieldset, array(), '<?php echo $this->getI18nCatalogue() ?>') ?]</h2>
  24.          [?php endif; ?]
  25.            <div class="fieldset-fields">
  26.         [?php
  27.             $newfields = array();
  28.             foreach($fields as $subname ){
  29.                 if ($subname[0] == "_")
  30.                 {
  31.                     include_partial('<?php $mn = $this->getModuleName(); echo $mn == "cpCms" ? "global":$mn; ?>/'.substr($subname, 1), array('form' => $embedded, "parent_form" => $form));
  32.                 }
  33.                 else
  34.                 {
  35.                     $field = $embedded[$subname]->getWidget();
  36.                     if (!$field->isHidden()){
  37.                         include_partial('<?php echo $this->getModuleName() ?>/form_field', array(
  38.                           'name'       => $subname,
  39.                           'attributes' => $field->getAttributes(),
  40.                           'label'      => $field->getLabel(),
  41.                           'help'       => $widget->getHelp($subname),/*$field->get('help')*/
  42.                           'form'       => $form[$name],
  43.                           'field'      => null,
  44.                           'class'      => 'form-row sf_admin_text sf_admin_form_field_'.$name,
  45.                         ));
  46.                      }
  47.                   }
  48.             }
  49.         ?]
  50.         </div>
  51.             </fieldset>
  52.  
  53.         [?php
  54.  
  55.         }
  56.     }
  57.     else
  58.     {
  59.         foreach ($widget->getFields() as $subname => $field){
  60.           if (!$field->isHidden()){
  61.             include_partial('<?php echo $this->getModuleName() ?>/form_field', array(
  62.               'name'       => $subname,
  63.               'attributes' => $field->getAttributes(),
  64.               'label'      => $field->getLabel(),
  65.               'help'       => $widget->getHelp($subname),/*$field->get('help')*/
  66.               'form'       => $form[$name],
  67.               'field'      => null,
  68.               'class'      => 'form-row sf_admin_text sf_admin_form_field_'.$name,
  69.             ));
  70.           }
  71.         }
  72.     }
  73.  
  74. }else {
  75. ?]
  76.     [?php if ($field != null && $field->isPartial()): ?]
  77.       [?php include_partial('<?php echo $this->getModuleName() ?>/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?]
  78.     [?php elseif ($field != null && $field->isComponent()): ?]
  79.       [?php include_component('<?php echo $this->getModuleName() ?>', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?]
  80.     [?php else: ?]
  81.       <div class="[?php echo $class ?][?php $form[$name]->hasError() and print ' has-error' ?]">
  82.         <div class="label">
  83.           [?php echo $form[$name]->renderLabel($label) ?]
  84.  
  85.           [?php if ($help || $help = $form[$name]->renderHelp()): ?]
  86.             <div class="help">
  87.               [?php echo __(strip_tags($help), array(), '<?php echo $this->getI18nCatalogue() ?>') ?]
  88.             </div>
  89.           [?php endif; ?]
  90.         </div>
  91.         [?php echo $form[$name]->render($use_attributes); ?]
  92.         [?php if ($form[$name]->hasError()): ?]
  93.           <div class="errors">
  94.             [?php echo $form[$name]->renderError() ?]
  95.           </div>
  96.         [?php endif; ?]
  97.       </div>
  98.     [?php endif; ?]
  99. [?php } ?]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement