Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -581,6 +581,14 @@ |
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
| 585 | + * Set the text for the submit button to a message |
| 586 | + * @param $msg String message key |
| 587 | + */ |
| 588 | + public function setSubmitTextMsg( $msg ) { |
| 589 | + return $this->setSubmitText( wfMsg( $msg ) ); |
| 590 | + } |
| 591 | + |
| 592 | + /** |
585 | 593 | * Get the text for the submit button, either customised or a default. |
586 | 594 | * @return unknown_type |
587 | 595 | */ |
— | — | @@ -619,6 +627,15 @@ |
620 | 628 | public function setWrapperLegend( $legend ) { $this->mWrapperLegend = $legend; } |
621 | 629 | |
622 | 630 | /** |
| 631 | + * Prompt the whole form to be wrapped in a <fieldset>, with |
| 632 | + * this message as its <legend> element. |
| 633 | + * @param $msg String message key |
| 634 | + */ |
| 635 | + public function setWrapperLegendMsg( $msg ) { |
| 636 | + return $this->setWrapperLegend( wfMsg( $msg ) ); |
| 637 | + } |
| 638 | + |
| 639 | + /** |
623 | 640 | * Set the prefix for various default messages |
624 | 641 | * TODO: currently only used for the <fieldset> legend on forms |
625 | 642 | * with multiple sections; should be used elsewhre? |
— | — | @@ -1357,6 +1374,8 @@ |
1358 | 1375 | return $p; |
1359 | 1376 | } |
1360 | 1377 | |
| 1378 | + print_r( $value ); |
| 1379 | + |
1361 | 1380 | $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
1362 | 1381 | |
1363 | 1382 | if ( in_array( $value, $validOptions ) ) |
— | — | @@ -1382,10 +1401,54 @@ |
1383 | 1402 | $select->setAttribute( 'disabled', 'disabled' ); |
1384 | 1403 | } |
1385 | 1404 | |
| 1405 | + if ( !empty( $this->mParams['multiple'] ) ) { |
| 1406 | + $select->setAttribute( 'name', $this->mName . '[]' ); |
| 1407 | + $select->setAttribute( 'multiple', 'multiple' ); |
| 1408 | + |
| 1409 | + if ( !empty( $this->mParams['size'] ) ) { |
| 1410 | + $select->setAttribute( 'size', $this->mParams['size'] ); |
| 1411 | + } |
| 1412 | + } |
| 1413 | + |
1386 | 1414 | $select->addOptions( $this->mParams['options'] ); |
1387 | 1415 | |
1388 | 1416 | return $select->getHTML(); |
1389 | 1417 | } |
| 1418 | + |
| 1419 | + /** |
| 1420 | + * @param $request WebRequest |
| 1421 | + * @return String |
| 1422 | + */ |
| 1423 | + function loadDataFromRequest( $request ) { |
| 1424 | + if ( $this->mParent->getMethod() == 'post' ) { |
| 1425 | + if( $request->wasPosted() ){ |
| 1426 | + # Checkboxes are just not added to the request arrays if they're not checked, |
| 1427 | + # so it's perfectly possible for there not to be an entry at all |
| 1428 | + return $request->getArray( $this->mName, array() ); |
| 1429 | + } else { |
| 1430 | + # That's ok, the user has not yet submitted the form, so show the defaults |
| 1431 | + return $this->getDefault(); |
| 1432 | + } |
| 1433 | + } else { |
| 1434 | + # This is the impossible case: if we look at $_GET and see no data for our |
| 1435 | + # field, is it because the user has not yet submitted the form, or that they |
| 1436 | + # have submitted it with all the options unchecked? We will have to assume the |
| 1437 | + # latter, which basically means that you can't specify 'positive' defaults |
| 1438 | + # for GET forms. |
| 1439 | + # @todo FIXME... |
| 1440 | + return $request->getArray( $this->mName, array() ); |
| 1441 | + } |
| 1442 | + } |
| 1443 | + |
| 1444 | + public static function keysAreValues( $array ) { |
| 1445 | + $resultArray = array(); |
| 1446 | + |
| 1447 | + foreach ( $array as $name => $value ) { |
| 1448 | + $resultArray[$value] = $value; |
| 1449 | + } |
| 1450 | + |
| 1451 | + return $resultArray; |
| 1452 | + } |
1390 | 1453 | } |
1391 | 1454 | |
1392 | 1455 | /** |
— | — | @@ -1861,7 +1924,7 @@ |
1862 | 1925 | |
1863 | 1926 | $this->mParent->addHiddenField( |
1864 | 1927 | $this->mName, |
1865 | | - $this->mDefault, |
| 1928 | + $value, |
1866 | 1929 | $params |
1867 | 1930 | ); |
1868 | 1931 | |