Advertisement
Guest User

Gravity form clone select instance

a guest
Nov 20th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. if(rgar($field,"cssClass") == "multi-choice"){
  2.     $string = "<label class='gfield_label'>".__( 'Choose a teacher', 'my_theme' )."</label>";
  3.     $string .= "<ul class='multi-select'>";
  4.    
  5.     $field_labels = array(1 => __( '1. choice', 'my_theme' ), 2 => __( '2. choice', 'my_theme' ),3 => __( '3. choice', 'my_theme' ));
  6.     for($i=1;$i<=3;$i++){
  7.         $string .= "<li>";
  8.         $field_string = preg_replace("/(input_\\d{1,2}_\\d{1,2})/is", "$1_$i", $content); //Adjust field and label ID
  9.         $field_string = preg_replace("/(<label[^>]+\>)(.*)(<\/label>)/s", "\$1"." ".$field_labels[$i]."$3", $field_string); //Replace each label
  10.         $string .= $field_string;
  11.         $string .= "</li>";
  12.     }
  13.     $string .= "</ul>";
  14.     $content = $string;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement