Fixed transaction ID edit

This commit is contained in:
Finn 2018-01-17 17:36:55 +00:00
parent 06e4345927
commit 25f9d818f8
2 changed files with 4 additions and 2 deletions

View file

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

View file

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