Commit cdce78cd authored by nepski's avatar nepski

feedback API side

parent d53aeed3
......@@ -13,7 +13,9 @@ class Main extends Controller {
function feedbackform($f3, $args) {
if ($f3->get('VERB') == 'GET'){
$f3->set('feedback_categories', Api::get_feedback_categories());
$categories = Api::get_feedback_categories()['categories'];
$f3->set('feedback_categories', $categories);
$f3->set("contact_id", 42);
//create call
......@@ -25,9 +27,10 @@ class Main extends Controller {
elseif ($f3->get('VERB') == 'POST'){
$contact_id = $f3->get('POST.contact_id');
$feedback = $f3->get('POST.feedback');
$category = $f3->get('POST.feedback_category');
//send feedback to campaign
$f3->set('post_feedback_result', Api::post_feedback($contact_id, $feedback));
$f3->set('post_feedback_result', Api::post_feedback($contact_id, $feedback, $category));
$f3->set('block_content', 'thankyou.html');
}
}
......
......@@ -68,6 +68,12 @@ class RestApi {
function categories($f3,$args) {
// List of feedback categories
echo'{"categories": [
"category1",
"category2",
"category3"
]
}';
}
function feedback_add($f3,$args) {
......
......@@ -7,15 +7,13 @@
<form method="post" action="/feedback/" >
<input type="text" id="contact_id" name="contact_id" hidden="hidden" value="{{ @contact_id }}" />
<repeat group="feedback_categories" value="feedback_category">
<p>
<input type="radio" group="feedback_category" value="{{ trim(@feedback_category }}" />
{{ trim(@feedback_category }}
</p>
<repeat group="{{ @feedback_categories }}" value="{{ @feedback_category }}">
<input type="radio" name="feedback_category" value="{{ @feedback_category }}" />
{{ @feedback_category }}
</repeat>
<textarea id="feedback" name="feedback"></textarea>
<p>
<textarea id="feedback" name="feedback"></textarea>
</p>
<input type="submit" name="go" value="{{ _("Send my feedback") }}" />
</form>
\ No newline at end of file
<p>thank you!</p>
<p>thank you! <3</p>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment