Index: trunk/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -416,27 +416,36 @@ |
417 | 417 | $displayCurrencyDropdown = isset( $displayCurrencyDropdown ) ? (boolean) $displayCurrencyDropdown : true; |
418 | 418 | $setCurrency = isset( $setCurrency ) ? (string) $setCurrency : ''; |
419 | 419 | $displayCurrencyDropdown = empty( $setCurrency ) ? $displayCurrencyDropdown : false; |
| 420 | + |
| 421 | + $amount = isset( $this->form_data['amount'] ) ? (string) $this->form_data['amount'] : '0'; |
| 422 | + |
| 423 | + // Treat values as string for comparison |
| 424 | + $amountValues = array('5', '10', '20', '35', '50', '100', '250',); |
420 | 425 | |
| 426 | + $isOther = in_array( $amount, $amountValues) ? false : true; |
| 427 | + $amountOther = $isOther ? $amount : ''; |
| 428 | + |
| 429 | + $checked = 'checked="checked" '; |
421 | 430 | // The text to return |
422 | 431 | $return = ''; |
423 | 432 | |
424 | 433 | $return .= '<table id="amount-radio">'; |
425 | 434 | $return .= ' <tr>'; |
426 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="5" /> 5</label></td>'; |
427 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="10" /> 10</label></td>'; |
428 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="20" /> 20</label></td>'; |
429 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="35" /> 35</label></td>'; |
| 435 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="5" ' . ( $amount == '5' ? $checked : '' ) . '/> 5</label></td>'; |
| 436 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="10" ' . ( $amount == '10' ? $checked : '' ) . '/> 10</label></td>'; |
| 437 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="20" ' . ( $amount == '20' ? $checked : '' ) . '/> 20</label></td>'; |
| 438 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="35" ' . ( $amount == '35' ? $checked : '' ) . '/> 35</label></td>'; |
430 | 439 | $return .= ' </tr>'; |
431 | 440 | $return .= ' <tr>'; |
432 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="50" /> 50</label></td>'; |
433 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="100" /> 100</label></td>'; |
434 | | - $return .= ' <td><label><input type="radio" name="amountRadio" value="250" /> 250</label></td>'; |
| 441 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="50" ' . ( $amount == '50' ? $checked : '' ) . '/> 50</label></td>'; |
| 442 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="100" ' . ( $amount == '100' ? $checked : '' ) . '/> 100</label></td>'; |
| 443 | + $return .= ' <td><label><input type="radio" name="amountRadio" value="250" ' . ( $amount == '250' ? $checked : '' ) . '/> 250</label></td>'; |
435 | 444 | $return .= ' <td>'; |
436 | | - $return .= ' <input type="radio" name="amountRadio" id="input_amount_other" value="other" />'; |
437 | | - $return .= ' <label><input type="text" class="txt-sm hint" name="amountGiven" size="4" id="other-amount" title="Other..." onfocus=""/></label>'; |
| 445 | + $return .= ' <input type="radio" name="amountRadio" id="input_amount_other" value="other" ' . ( $isOther ? $checked : '' ) . ' />'; |
| 446 | + $return .= ' <label><input type="text" class="txt-sm hint" name="amountGiven" size="4" id="other-amount" title="Other..." onfocus="" value="' . $amountOther . '" /></label>'; |
438 | 447 | |
439 | 448 | // Add hidden amount field for validation |
440 | | - $return .= Html::hidden( 'amount', 0 ); |
| 449 | + $return .= Html::hidden( 'amount', $amount ); |
441 | 450 | |
442 | 451 | // Set currency |
443 | 452 | if ( !empty( $setCurrency ) ) { |