daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buzzd_form_field($opts)
  2. {
  3.   $edit_enabled = BuzzdHelper::getSettings()->get('form edit enabled');
  4.   $field = $opts['field'];
  5.   $is_textarea = false;
  6.   $is_input = false;
  7.   switch (get_class($field->getWidget())) {
  8.     case 'sfWidgetFormInput': {
  9.       $is_input = true;    
  10.       break;
  11.     } case 'sfWidgetFormTextarea': {
  12.       $is_textarea = true;
  13.       break;
  14.     } case 'sfWidgetFormSelectRadio': {
  15.       $is_radio = true;
  16.       break;
  17.     } case 'sfWidgetFormInputFile': {
  18.       $is_input = true;
  19.       break;
  20.     }
  21.     default: d::ve(get_class($field->getWidget()),2);
  22.   }
  23.   if ($is_textarea||$is_input) {
  24.     $field->getWidget()->setAttribute('class','generic-input');
  25.   } elseif ($is_radio) {
  26.     $field->getWidget()->setOption('formatter',array(new __BuzzdRadioFormatter(),'formatter'));
  27.     if (isset($opts['choices'])) {
  28.       $field->getWidget()->setOption('choices',$opts['choices']);
  29.     }
  30.   }
  31.   $multiline = ('multiline'===$opts['left or right']);
  32.   ob_start();
  33.   ?>
  34.  
  35.   <?php if (!$multiline): ?> <div class="detail-column <?php echo $opts['left or right'] ?>"> <?php endif ?>
  36.       <span class="user-detail-title"><?php echo $field->renderLabel()?></span>
  37.       <div class="user-detail-text<?php $multiline and print(' user-detail-text-multiline') ?>">
  38.           <div class='view-field'><?php
  39.             if (strlen($field->getValue())) {
  40.               if (isset($opts['choices'])) {
  41.                 echo $opts['choices'][$field->getValue()];
  42.               } else {
  43.                 echo $field->getValue();
  44.               }
  45.             } else {
  46.               echo "<div class='prop blank-textarea-height'>&nbsp;</div>\n";
  47.             }
  48.           ?></div>      
  49.           <div class='edit-field'>
  50.             <?php echo $field ?>
  51.             <?php if (isset($opts['note'])) : ?>
  52.               <div class='generic-field-note'><em><?php echo $opts['note'] ?></em></div>
  53.             <?php endif; ?>
  54.           </div>
  55.         <?php if ($field->hasError()): ?>
  56. <?php echo $field->renderError() ?>        
  57.          <?php /* <ul class='error-list-small'><li><?php echo $field->renderError() ?></li></ul> */ ?>
  58.         <?php endif; ?>
  59.        
  60.       </div>
  61.   <?php if (!$multiline): ?></div><?php endif ?>
  62.   <?php
  63.   return ob_get_clean();
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top