Advertisement
Guest User

Multi Field in repeatable Form

a guest
Jan 4th, 2013
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. array(
  2.                 'label' =>  __('Quiz Contents', 'framework'),
  3.                 'desc' => __('Create quiz question, answer, and options', 'framework'),
  4.                 'id' => $prefix . 'frenzy_quiz',
  5.                 'type' => 'repeatable-group',
  6.                 'groupfield' => array(
  7.                         array( 'label' =>  __('Name of the artist', 'framework'),
  8.                                'type' =>  'text',
  9.                         ),
  10.                         array( 'label' =>  __('Artist Album List', 'framework'),
  11.                                'type' =>  'textarea',
  12.                         ),
  13.                         array( 'label' =>  __('Artist Homepage', 'framework'),
  14.                                'type' =>  'text',
  15.                         ),
  16.                 ),
  17.                 'location' => 'post',
  18.         ),
  19.  
  20. case 'repeatable-group':
  21.                             echo '<a class="repeatable-add button" href="#">+' . __('Add Row','framework') . '</a>
  22.                                     <ul id="'.$field['id'].'-repeatable" class="custom_repeatable repeatable_group">';
  23.                             $i = 0;
  24.                             if($meta) {
  25.                                 foreach($meta as $row) {
  26.                                     $j = 0;
  27.                                     echo '<li>';
  28.                                     foreach($field['groupfield'] as $groupfield) {
  29.                                         switch ($groupfield['type']) {
  30.  
  31.                                         case 'text':
  32.                                         echo '
  33.                                                 <p><label>'.$groupfield['label'].'</label><input size="30" type="text" name="'.$field['id'].'['.$i.']['.$j.']" id="'.$field['id'].'" value="" size="30" /></p>';
  34.                                        
  35.                                         break;
  36.                                         case 'textarea':
  37.                                         echo '<p><label>'.$groupfield['label'].'</label>
  38.                                         <textarea name="'.$field['id'].'['.$i.']['.$j.']" id="'.$field['id'].'" row="20" cols="35"></textarea>
  39.                                         </p>';
  40.  
  41.                                         break;
  42.                                         }
  43.  
  44.                                         $j++;
  45.                                     }
  46.                                     echo '<a class="repeatable-remove button" href="#">-</a></li>';
  47.                                    
  48.                                     $i++;
  49.                                 }
  50.                                
  51.                             }
  52.                             else {
  53.                                 $j = 0;
  54.                                 echo '<li>';
  55.                                 foreach($field['groupfield'] as $groupfield) {
  56.                                     switch ($groupfield['type']) {
  57.  
  58.                                     case 'text':
  59.                                     echo '
  60.                                             <p><label>'.$groupfield['label'].'</label><input size="30" type="text" name="'.$field['id'].'['.$i.']['.$j.']" id="'.$field['id'].'" value="" size="30" /></p>';
  61.                                    
  62.                                     break;
  63.                                     case 'textarea':
  64.                                     echo '<p><label>'.$groupfield['label'].'</label>
  65.                                     <textarea name="'.$field['id'].'['.$i.']['.$j.']" id="'.$field['id'].'" row="20" cols="35"></textarea>
  66.                                     </p>';
  67.  
  68.                                     break;
  69.                                     }
  70.  
  71.                                     $j++;
  72.                                 }
  73.                                 echo '<a class="repeatable-remove button" href="#">-</a></li>';
  74.                                
  75.                             }
  76.                             echo '</ul>
  77.                                 <span class="description">'.$field['desc'].'</span>';
  78.                         break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement