| 407 | ### SelectGrouped Widget |
| 408 | |
| 409 | >>> choices = [] |
| 410 | >>> choices.append(('label for group 1', [('value1', 'label1'), ('value2', 'label2')])) |
| 411 | >>> choices.append(('label for group 2', [('value3', 'label3'), ('value4', 'label4')])) |
| 412 | >>> w = SelectGrouped(choices=choices) |
| 413 | >>> print w.render('name','value1') |
| 414 | <select name="name"> |
| 415 | <optgroup label="label for group 1"> |
| 416 | <option value="value1" selected="selected">label1</option> |
| 417 | <option value="value2">label2</option> |
| 418 | </optgroup> |
| 419 | <optgroup label="label for group 2"> |
| 420 | <option value="value3">label3</option> |
| 421 | <option value="value4">label4</option> |
| 422 | </optgroup> |
| 423 | </select> |
| 424 | |
| 425 | >>> choices = [] |
| 426 | >>> choices.append(('label for group 1', [['value1', 'label1'], ['value2', 'label2']])) |
| 427 | >>> choices.append(('label for group 2', [['value3', 'label3'], ['value4', 'label4']])) |
| 428 | >>> w = SelectGrouped(choices=choices) |
| 429 | >>> print w.render('name','value1') |
| 430 | <select name="name"> |
| 431 | <optgroup label="label for group 1"> |
| 432 | <option value="value1" selected="selected">label1</option> |
| 433 | <option value="value2">label2</option> |
| 434 | </optgroup> |
| 435 | <optgroup label="label for group 2"> |
| 436 | <option value="value3">label3</option> |
| 437 | <option value="value4">label4</option> |
| 438 | </optgroup> |
| 439 | </select> |
| 440 | |
| 441 | >>> choices = [] |
| 442 | >>> choices.append(['label for group 1', [['value1', 'label1'], ['value2', 'label2']]]) |
| 443 | >>> choices.append(['label for group 2', [['value3', 'label3'], ['value4', 'label4']]]) |
| 444 | >>> w = SelectGrouped(choices=choices) |
| 445 | >>> print w.render('name','value1') |
| 446 | <select name="name"> |
| 447 | <optgroup label="label for group 1"> |
| 448 | <option value="value1" selected="selected">label1</option> |
| 449 | <option value="value2">label2</option> |
| 450 | </optgroup> |
| 451 | <optgroup label="label for group 2"> |
| 452 | <option value="value3">label3</option> |
| 453 | <option value="value4">label4</option> |
| 454 | </optgroup> |
| 455 | </select> |
| 456 | |
| 457 | ### SelectMultipleGrouped Widget |
| 458 | >>> choices = [] |
| 459 | >>> choices.append(('label for group 1', [('value1', 'label1'), ('value2', 'label2')])) |
| 460 | >>> choices.append(('label for group 2', [('value3', 'label3'), ('value4', 'label4')])) |
| 461 | >>> w = SelectMultipleGrouped(choices=choices) |
| 462 | >>> print w.render('name',['value1','value3']) |
| 463 | <select multiple="multiple" name="name"> |
| 464 | <optgroup label="label for group 1"> |
| 465 | <option value="value1" selected="selected">label1</option> |
| 466 | <option value="value2">label2</option> |
| 467 | </optgroup> |
| 468 | <optgroup label="label for group 2"> |
| 469 | <option value="value3" selected="selected">label3</option> |
| 470 | <option value="value4">label4</option> |
| 471 | </optgroup> |
| 472 | </select> |
| 473 | |
| 474 | >>> choices = [] |
| 475 | >>> choices.append(('label for group 1', [['value1', 'label1'], ['value2', 'label2']])) |
| 476 | >>> choices.append(('label for group 2', [['value3', 'label3'], ['value4', 'label4']])) |
| 477 | >>> w = SelectMultipleGrouped(choices=choices) |
| 478 | >>> print w.render('name',['value1']) |
| 479 | <select multiple="multiple" name="name"> |
| 480 | <optgroup label="label for group 1"> |
| 481 | <option value="value1" selected="selected">label1</option> |
| 482 | <option value="value2">label2</option> |
| 483 | </optgroup> |
| 484 | <optgroup label="label for group 2"> |
| 485 | <option value="value3">label3</option> |
| 486 | <option value="value4">label4</option> |
| 487 | </optgroup> |
| 488 | </select> |
| 489 | |
| 490 | >>> choices = [] |
| 491 | >>> choices.append(['label for group 1', [['value1', 'label1'], ['value2', 'label2']]]) |
| 492 | >>> choices.append(['label for group 2', [['value3', 'label3'], ['value4', 'label4']]]) |
| 493 | >>> w = SelectMultipleGrouped(choices=choices) |
| 494 | >>> print w.render('name',('value1','value4')) |
| 495 | <select multiple="multiple" name="name"> |
| 496 | <optgroup label="label for group 1"> |
| 497 | <option value="value1" selected="selected">label1</option> |
| 498 | <option value="value2">label2</option> |
| 499 | </optgroup> |
| 500 | <optgroup label="label for group 2"> |
| 501 | <option value="value3">label3</option> |
| 502 | <option value="value4" selected="selected">label4</option> |
| 503 | </optgroup> |
| 504 | </select> |
| 505 | |
| 506 | |