Update add org to work with new form

This commit is contained in:
Tom Bloor 2017-09-04 14:09:36 +01:00
parent 2ef5193e41
commit 4fa52901cb
2 changed files with 49 additions and 14 deletions

View file

@ -29,6 +29,7 @@ sub add_org_submit {
$validation->required('town'); $validation->required('town');
$validation->optional('sector'); $validation->optional('sector');
$validation->optional('postcode')->postcode; $validation->optional('postcode')->postcode;
$validation->optional('pending');
if ( $validation->has_error ) { if ( $validation->has_error ) {
$c->flash( error => 'The validation has failed' ); $c->flash( error => 'The validation has failed' );
@ -45,6 +46,8 @@ sub add_org_submit {
town => $validation->param('town'), town => $validation->param('town'),
sector => $validation->param('sector'), sector => $validation->param('sector'),
postcode => $validation->param('postcode'), postcode => $validation->param('postcode'),
submitted_by_id => $c->current_user->id,
pending => defined $validation->param('pending') ? 0 : 1,
}, },
type => 'organisation', type => 'organisation',
}); });

View file

@ -15,19 +15,51 @@
<h3 class="card-header"> <h3 class="card-header">
Add an Organisation Add an Organisation
</h3> </h3>
<ul class="list-group list-group-flush"> <div class="card-block">
<form action="<%= url_for . '/submit' %>" method="post"> <form action="<%= url_for %>" method="post">
<li class="list-group-item">Only 'Organisation Name' and 'Town' are required entries.</li> <div class="form-group row">
<li class="list-group-item"><input id="name" type="text" class="form-control" placeholder="Organisation Name" name="name"></li> <label for="name" class="col-sm-2 col-form-label">Organisation Name</label>
<li class="list-group-item"><input id="street_name" type="text" class="form-control" placeholder="Street Name" name="street_name"></li> <div class="col-sm-10">
<li class="list-group-item"><input id="town" type="text" class="form-control" placeholder="Town" name="town"></li> <input id="name" type="text" class="form-control" placeholder="Organisation Name" name="name">
<li class="list-group-item"> </div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Street Name</label>
<div class="col-sm-10">
<input id="street_name" type="text" class="form-control" placeholder="Street Name" name="street_name">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Town/City</label>
<div class="col-sm-10">
<input id="town" type="text" class="form-control" placeholder="Town" name="town">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Sector</label>
<div class="col-sm-10">
<select class="form-control" name="sector"> <select class="form-control" name="sector">
%= include 'partials/sector_options', selected_sector => ''; %= include 'partials/sector_options', selected_sector => '';
</select> </select>
</li> </div>
<li class="list-group-item"><input id="postcode" type="text" class="form-control" placeholder="Postcode" name="postcode"></li> </div>
<li class="list-group-item"><button class="btn btn-success" type="submit">Add Organisation</button></li> <div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Postcode</label>
<div class="col-sm-10">
<input id="postcode" type="text" class="form-control" placeholder="Postcode" name="postcode">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Validated</label>
<div class="col-sm-10">
<input id="pending" type="checkbox" name="pending" value="0">
</div>
</div>
<div class="form-group row">
<div class="ml-auto col-sm-10">
<button class="btn btn-success" type="submit">Save Changes To Organisation</button>
</div>
</div>
</form> </form>
</ul> </div>
</div> </div>