PhloTour
EN NL
08 / 30

Async forms

One route, two transports. The page updates with no reload and no JavaScript written.

Read the docs →
.phlo
// one route, two transports. no JavaScript written.
route both POST poll vote $id {
	if (!$o = poll::record(id: (int)$id)) return false
	poll::change('id=?', (int)$id, votes: $o->votes + 1)
	if (%req->async) return apply(outer: ['#results' => $this->results])
	location(slash)
}

view choices:
<foreach poll::records() AS $o>
	<form.async method=post action="/poll/vote/$o->id">
		<button>$o->option</button>
	</form>
</foreach>
		
Phlo 41%
Rails 29%
Laravel 18%
Django 12%