Fixed transaction ID edit

This commit is contained in:
Finn 2018-01-17 17:36:55 +00:00
parent 3e9746ca22
commit cd4f13bf8c
2 changed files with 4 additions and 2 deletions

View file

@ -57,6 +57,7 @@ sub read {
sub update { sub update {
my $c = shift; my $c = shift;
my $validation = $c->validation; my $validation = $c->validation;
$validation->required('id');
$validation->required('category', 'trim')->like(qr/^[\w]*$/); $validation->required('category', 'trim')->like(qr/^[\w]*$/);
my $id = $c->param('id'); my $id = $c->param('id');
@ -67,6 +68,7 @@ sub update {
$c->redirect_to( '/admin/categories/' . $id ); $c->redirect_to( '/admin/categories/' . $id );
} elsif ( my $category = $c->result_set->find($id) ) { } elsif ( my $category = $c->result_set->find($id) ) {
$category->update({ $category->update({
id => $validation->param('id'),
name => $validation->param('category'), name => $validation->param('category'),
}); });
$c->flash( success => 'Category Updated' ); $c->flash( success => 'Category Updated' );

View file

@ -18,8 +18,8 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="category-id">Token ID</label> <label for="category-id">Token ID</label>
<input id="category-id" type="text" class="form-control" placeholder="Token ID" name="category" value="<%= $category->id %>"> <input id="category-id" type="text" class="form-control" placeholder="Token ID" name="id" value="<%= $category->id %>">
<p class="help-block">Do not change the ID unless <strong>absolutely</strong> necessary.</p> <p class="help-block">Do not change the ID unless <strong>absolutely</strong> necessary. This will result in an error reading as it can no longer find it from the same ID.</p>
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary form-control" type="submit">Update</button> <button class="btn btn-primary form-control" type="submit">Update</button>