Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | |
49 | 49 | # Get posted form values if any |
50 | 50 | $posted = array(); |
51 | | - foreach ( $_REQUEST as $k => $v ) if ( ereg( '^ra_(.+)$', $k, $m ) ) $posted[$m[1]] = $v; |
| 51 | + foreach ( $_REQUEST as $k => $v ) if ( preg_match( '|^ra_(\\w+)|', $k, $m ) ) $posted[$m[1]] = is_array( $v ) ? join( "\n", $v ) : $v; |
52 | 52 | |
53 | 53 | # Read in and prepare the form for this record type if one has been selected |
54 | 54 | if ( $type ) $this->preProcessForm( $type ); |
— | — | @@ -450,10 +450,10 @@ |
451 | 451 | if ( !is_array( $values ) ) $values = $this->valuesFromText( $values ); |
452 | 452 | |
453 | 453 | # Add the values into the form's HTML depending on their type |
454 | | - foreach ( $this->types as $k => $type ) { |
| 454 | + foreach( $this->types as $k => $type ) { |
455 | 455 | |
456 | 456 | # Get this input element's html text and position and length |
457 | | - preg_match( "|<([a-zA-Z]+)[^<]+?name=\"ra_$k\".*?>(.*?</\\1>)?|s", $this->form, $m, PREG_OFFSET_CAPTURE ); |
| 457 | + preg_match( "|<([a-zA-Z]+)[^<]+?name=\"ra_$k\\[?\\]?\".*?>(.*?</\\1>)?|s", $this->form, $m, PREG_OFFSET_CAPTURE ); |
458 | 458 | list( $html, $pos ) = $m[0]; |
459 | 459 | $len = strlen( $html ); |
460 | 460 | |
— | — | @@ -471,11 +471,15 @@ |
472 | 472 | break; |
473 | 473 | case 'list': |
474 | 474 | $html = preg_replace_callback("|\{\{.+\}\}|s", array($this, 'parsePart'), $html); # parse any braces |
475 | | - if ( empty( $this->record ) ) $html = preg_replace( "|(<option[^<>]*) selected|", "$1", $html ); # remove the currently selected option |
| 475 | + #if ( empty( $this->record ) ) |
| 476 | + $html = preg_replace( "|(<option[^<>]*) selected|", "$1", $html ); # remove the currently selected option |
476 | 477 | if ( $v ) { |
477 | | - $html = preg_match( "|<option[^>]+value\s*=|s", $html ) |
478 | | - ? preg_replace( "|(<option)([^>]+value\s*=\s*[\"']{$v}['\"])|s", "$1 selected$2", $html ) |
479 | | - : preg_replace( "|(<option[^>]*)(?=>$v</option>)|s", "$1 selected", $html ); |
| 478 | + foreach( split( "\n", $v ) as $v ) { |
| 479 | + print $v; |
| 480 | + $html = preg_match( "|<option[^>]+value\s*=|s", $html ) |
| 481 | + ? preg_replace( "|(<option)([^>]+value\s*=\s*[\"']{$v}['\"])|s", "$1 selected$2", $html ) |
| 482 | + : preg_replace( "|(<option[^>]*)(?=>$v</option>)|s", "$1 selected", $html ); |
| 483 | + } |
480 | 484 | } |
481 | 485 | break; |
482 | 486 | case 'blob': |
— | — | @@ -504,7 +508,7 @@ |
505 | 509 | */ |
506 | 510 | function examineForm() { |
507 | 511 | $this->types = array(); |
508 | | - preg_match_all( "|<([a-zA-Z]+)[^<]+?name=\"ra_(.+?)\".*?>|", $this->form, $m ); |
| 512 | + preg_match_all( "|<([a-zA-Z]+)[^<]+?name=\"ra_(.+?)\\[?\\]?\".*?>|", $this->form, $m ); |
509 | 513 | foreach ( $m[2] as $i => $k ) { |
510 | 514 | $tag = $m[1][$i]; |
511 | 515 | $type = preg_match( "|type\s*=\s*\"(.+?)\"|", $m[0][$i], $n ) ? $n[1] : ''; |