[dw-free] create new promo code should have 'active' box checked
[commit: http://hg.dwscoalition.org/dw-free/rev/4e2142c9613b]
http://bugs.dwscoalition.org/show_bug.cgi?id=3928
Check the "active" box by default when creating a new promo code, and save
state properly through page loads.
Patch by
rb.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3928
Check the "active" box by default when creating a new promo code, and save
state properly through page loads.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- htdocs/admin/invites/promo.bml
-------------------------------------------------------------------------------- diff -r 9b6f4fa5ccc3 -r 4e2142c9613b htdocs/admin/invites/promo.bml --- a/htdocs/admin/invites/promo.bml Mon Sep 12 15:45:20 2011 +0800 +++ b/htdocs/admin/invites/promo.bml Mon Sep 12 15:52:33 2011 +0800 @@ -34,6 +34,7 @@ my $data = $_[0] || {}; my $errors = $_[1] || {}; my $suggest_u = ( $data && $data->{suggest_journalid} ) ? LJ::load_userid($data->{suggest_journalid}) : undef; + my $active = ( defined $data->{active} ) ? $data->{active} : 1; if ( $state eq 'create' ) { $title = $ML{'.title.create'}; @@ -46,7 +47,7 @@ $ret .= "<form method='POST' action='/admin/invites/promo'>"; $ret .= LJ::form_auth(); $ret .= LJ::html_hidden( { name => 'state', value => $state }); - $ret .= LJ::html_check( { id => 'active', name => 'active', value => 1, selected => $data->{active}, label => $ML{'.field.active.label'} } ); + $ret .= LJ::html_check( { id => 'active', name => 'active', value => 0, selected => $active, label => $ML{'.field.active.label'} } ); $ret .= " <strong>[$ML{'.error.label'} " . join(', ', @{$errors->{active}}) . "]</strong>" if $errors->{active}; $ret .= '<br />'; if ( $state eq 'create' ) { @@ -97,7 +98,7 @@ $state = lc( $POST{state} || "" ); if ( $state eq 'create' ) { my $data = { - active => $POST{active} ? 1 : 0, + active => defined( $POST{active} ) ? 1 : 0, code => $code, current_count => 0, max_count => $POST{max_count} || 0, --------------------------------------------------------------------------------