"""If the db is completely deleted then we get an error as the iteration is over an empty table."""
db.post.insert(message="Well_hest")# well_hest is an internal keyword/trigger word
{{extend "layout.html"}}
<!DOCTYPE html>
<html lang="en">
<head>
<title>convForm - example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<link href="{{=URL('static', 'css/jquery.convform.css')}}" rel="stylesheet" type="text/css" />
<link href="{{=URL('static', 'css/demo.css')}}" rel="stylesheet" type="text/css" />
</head>
<body>
<section id="demo">
<div id="target"></div>
<div class="vertical-align">
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3 col-xs-offset-0">
<div class="card no-border">
<div id="chat" class="conv-form-wrapper">
<form action="#" enctype="multipart/form-data" method="post" id="myform" class="hidden">
<select data-conv-question="Hello! I'm a bot created from a HTML form. Can I show you some features? (this question comes from a select)">
<option value="yes">Yes</option>
<option value="sure">Sure!</option>
</select>
<input type="text" name="message" id="message" data-conv-question="Alright! First, tell me your full name, please.|Okay! Please, tell me your name first.">
<input type="text" data-conv-question="{{=reports}}" data-no-answer="true">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script type="text/javascript" src="jquery-1.12.3.min.js"></script>
<script src="{{=URL('static','js/jquery-1.12.3.min.js')}}" type="text/javascript"></script>
<script src="{{=URL('static','js/autosize.min.js')}}" type="text/javascript"></script>
<script src="{{=URL('static','js/jquery.convform.js')}}" type="text/javascript"></script>
<script>
var rollbackTo = false;
var originalState = false;
function storeState(stateWrapper) {
rollbackTo = stateWrapper.current;
console.log("storeState called: ",rollbackTo);
}
function rollback(stateWrapper) {
console.log("rollback called: ", rollbackTo, originalState);
console.log("answers at the time of user input: ", stateWrapper.answers);
if(rollbackTo!=false) {
if(originalState==false) {
originalState = stateWrapper.current.next;
console.log('stored original state');
}
stateWrapper.current.next = rollbackTo;
console.log('changed current.next to rollbackTo');
}
}
function restore(stateWrapper) {
if(originalState != false) {
stateWrapper.current.next = originalState;
console.log('changed current.next to originalState');
}
}
jQuery('#myform').submit(function() {
ajax('{{=URL('search')}}', '#myform', 'target');
return false;
});
</script>
</body>
</html>
With the code above, see the images attached.
You'll note that if I post a query like: 'testing 123' it will be posted to the post table as shown in the image. But retrieving it back to the controller, just for the purpose of retrieving what is posted, I get 'maurice' which is a previous post instead.
This is my biggest headache. That is why i tried getting a way to refresh the Db, or using request.now (thinking that it will get the response with current time)