delphimvcframework/samples/serversideviews_lua/bin/templates/editperson.elua

77 lines
2.8 KiB
Plaintext
Raw Normal View History

<script>
function doDelete(id) {
if (confirm('Are you sure?')) {
let form = document.getElementById("myForm");
form.action = "/deleteperson";
form.submit();
}
}
</script>
<div class="row_fluid">
<div class="col-sm-12">
<form class="form form-horizontal" id="myForm" name="myForm" method="POST" action="/people">
<input type="hidden" value="<?lua=person.guid ?>" name="guid">
<div class="row">
<div class="col-sm-offset-2 col-sm-8">
<?lua if person.guid == '' then?>
<h3>New Person</h3>
<?lua else ?>
<h3>Edit Person</h3>
<?lua end ?>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="first_name" class="col-sm-2 control-label">First name</label>
<div class="col-sm-4">
<input type="text" value="<?lua=person.first_name ?>" class="form-control" id="first_name" placeholder="First name" name="first_name">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="last_name" class="col-sm-2 control-label">Last name</label>
<div class="col-sm-4">
<input type="text" value="<?lua=person.last_name ?>" class="form-control" id="last_name" placeholder="Last name" name="last_name">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="age" class="col-sm-2 control-label">Age</label>
<div class="col-sm-4">
<input type="number" value="<?lua=person.age ?>" class="form-control" id="age" placeholder="Age" name="age">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="items" class="col-sm-2 control-label">Devices</label>
<div class="col-sm-4">
<select name="items" multiple class="form-control">
<?lua for _, device in ipairs(deviceslist) do ?>
<option value="<?lua= device.DeviceName ?>" <?lua if device.Selected then elua_out('selected') end?>><?lua= device.DeviceName ?></option>
<?lua end ?>
</select>
<span style="font-size: 80%">(Ctrl+Click to select multiple devices)</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-2">
<button type="button" class="btn btn-default btn-block" onclick="history.back()">Return to the list</button>
</div>
<div class="col-sm-2">
<?lua if person ~= nil then ?>
<button type="button" onclick="doDelete()" class="btn btn-primary btn-block">Delete</button>
<?lua end ?>
<button type="submit" class="btn btn-primary btn-block">Save</button>
</div>
</div>
</form>
</div>
</div>