Skip to content

Commit 58ee4cf

Browse files
author
arutyunyan
committed
add input model value
1 parent a97a36c commit 58ee4cf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/frontend/example/TodoList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public function view()
1616
type="text"
1717
class="form-control"
1818
placeholder="What needs to be done?"
19-
aria-describedby="button-add">
19+
aria-describedby="button-add"'.
20+
$this->inputValue('task')
21+
.'>
2022
<button
2123
type="button"
2224
class="btn btn-primary">

src/frontend/html/component/Component.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ public function button()
135135
return new Button;
136136
}
137137

138+
public function inputValue($name)
139+
{
140+
$id = uniqid();
141+
142+
$this->scope->addVariable($name)->setCallback($id, 'function (el, value) { el.value = value }');
143+
144+
return ' id="'.$id.'"';
145+
}
146+
138147
public function range($start, $end, $callback)
139148
{
140149
$str = '';

0 commit comments

Comments
 (0)