Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -373,7 +373,6 @@ |
374 | 374 | |
375 | 375 | global $sfgTabIndex, $sfgFieldNum, $wgOut, $sfgScriptPath, $wgJsMimeType; |
376 | 376 | global $smwgScriptPath, $smwgJqUIAutoIncluded; |
377 | | - global $sfgAutocompleteMappings; |
378 | 377 | |
379 | 378 | $autocomplete_field_type = ""; |
380 | 379 | $autocompletion_source = ""; |
— | — | @@ -401,10 +400,8 @@ |
402 | 401 | |
403 | 402 | $input_id = "input_" . $sfgFieldNum; |
404 | 403 | |
405 | | - $options_str_key = str_replace( "'", "\'", $autocompletion_source ); |
406 | | - $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key; |
407 | | - |
408 | 404 | $values = SFUtils::getAutocompleteValues($autocompletion_source, $autocomplete_field_type ); |
| 405 | + $autocompletion_source = str_replace( "'", "\'", $autocompletion_source ); |
409 | 406 | |
410 | 407 | /*adding code for displaying dropdown of autocomplete values*/ |
411 | 408 | |
— | — | @@ -412,7 +409,7 @@ |
413 | 410 | if ($is_mandatory) { $divClass .= " mandatory"; } |
414 | 411 | $text =<<<END |
415 | 412 | <div class="$divClass"> |
416 | | - <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex"> |
| 413 | + <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex" autocompletesettings="$autocompletion_source"> |
417 | 414 | <option value="$cur_value"></option> |
418 | 415 | |
419 | 416 | END; |
— | — | @@ -450,7 +447,7 @@ |
451 | 448 | return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
452 | 449 | |
453 | 450 | global $sfgTabIndex, $sfgFieldNum, $sfgScriptPath, $wgJsMimeType, $smwgScriptPath, $smwgJqUIAutoIncluded; |
454 | | - global $sfgAutocompleteMappings, $sfgAutocompleteDataTypes, $sfgAutocompleteValues; |
| 451 | + global $sfgAutocompleteDataTypes, $sfgAutocompleteValues; |
455 | 452 | |
456 | 453 | $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput"; |
457 | 454 | if ( array_key_exists( 'class', $other_args ) ) |
— | — | @@ -464,6 +461,22 @@ |
465 | 462 | } |
466 | 463 | } |
467 | 464 | $input_id = "input_" . $sfgFieldNum; |
| 465 | + |
| 466 | + // Set autocomplete-settings attribute, and delimiter value (it's needed |
| 467 | + // also for the 'uploadable' link, if there is one). |
| 468 | + $autocompleteSettings = $autocompletion_source; |
| 469 | + $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ); |
| 470 | + if ( $is_list ) { |
| 471 | + $autocompleteSettings .= ",list"; |
| 472 | + if ( array_key_exists( 'delimiter', $other_args ) ) { |
| 473 | + $delimiter = $other_args['delimiter']; |
| 474 | + $autocompleteSettings .= "," . $delimiter; |
| 475 | + } else { |
| 476 | + $delimiter = ","; |
| 477 | + } |
| 478 | + } else { |
| 479 | + $delimiter = null; |
| 480 | + } |
468 | 481 | if ( array_key_exists( 'input_type', $other_args ) && $other_args['input_type'] == "textarea" ) { |
469 | 482 | |
470 | 483 | $rows = $other_args['rows']; |
— | — | @@ -480,6 +493,7 @@ |
481 | 494 | 'rows' => $rows, |
482 | 495 | 'cols' => $cols, |
483 | 496 | 'class' => $className, |
| 497 | + 'autocompletesettings' => $autocompleteSettings, |
484 | 498 | ); |
485 | 499 | if ( $is_disabled ) { |
486 | 500 | $textarea_attrs['disabled'] = 'disabled'; |
— | — | @@ -512,6 +526,7 @@ |
513 | 527 | 'size' => $size, |
514 | 528 | 'class' => $className, |
515 | 529 | 'tabindex' => $sfgTabIndex, |
| 530 | + 'autocompletesettings' => $autocompleteSettings, |
516 | 531 | ); |
517 | 532 | if ( $is_disabled ) { |
518 | 533 | $inputAttrs['disabled'] = 'disabled'; |
— | — | @@ -521,17 +536,6 @@ |
522 | 537 | } |
523 | 538 | $text = "\n\t" . Xml::element( 'input', $inputAttrs ) . "\n"; |
524 | 539 | } |
525 | | - // is_list and delimiter variables - needed later |
526 | | - $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ); |
527 | | - if ( $is_list ) { |
528 | | - if ( array_key_exists( 'delimiter', $other_args ) ) { |
529 | | - $delimiter = $other_args['delimiter']; |
530 | | - } else { |
531 | | - $delimiter = ","; |
532 | | - } |
533 | | - } else { |
534 | | - $delimiter = null; |
535 | | - } |
536 | 540 | if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) { |
537 | 541 | if ( array_key_exists( 'default filename', $other_args ) ) { |
538 | 542 | $default_filename = $other_args['default filename']; |
— | — | @@ -545,20 +549,12 @@ |
546 | 550 | if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
547 | 551 | $text = "\n" . Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
548 | 552 | |
549 | | - $options_str_key = $autocompletion_source; |
550 | | - if ( $is_list ) { |
551 | | - $options_str_key .= ",list"; |
552 | | - if ( $delimiter != "," ) { |
553 | | - $options_str_key .= "," . $delimiter; |
554 | | - } |
555 | | - } |
556 | | - $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key; |
557 | 553 | if ( array_key_exists( 'remote autocompletion', $other_args ) && |
558 | 554 | $other_args['remote autocompletion'] == true ) { |
559 | | - $sfgAutocompleteDataTypes[$options_str_key] = $autocomplete_field_type; |
| 555 | + $sfgAutocompleteDataTypes[$autocompleteSettings] = $autocomplete_field_type; |
560 | 556 | } elseif ( $autocompletion_source != '' ) { |
561 | 557 | $autocomplete_values = SFUtils::getAutocompleteValues( $autocompletion_source, $autocomplete_field_type ); |
562 | | - $sfgAutocompleteValues[$options_str_key] = $autocomplete_values; |
| 558 | + $sfgAutocompleteValues[$autocompleteSettings] = $autocomplete_values; |
563 | 559 | } |
564 | 560 | return $text; |
565 | 561 | } |