Create function to pass data to html through twig

This commit is contained in:
Gregorio Chiko Putra 2017-09-04 15:35:11 +07:00
parent 424737117a
commit aa60edbbf0
2 changed files with 25 additions and 15 deletions

View File

@ -23,7 +23,17 @@ class Posts
{
if ($id) {
// echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html
View::render('Data/edit_pengumuman.html');
View::render(
'Data/edit_pengumuman.html',
[
'category' => 4,
'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
'created_at' => '2017-05-10 10:00',
'creator' => '5',
'edited_at' => '2017-08-10 10:00',
'editor' => '8'
]
);
return true;
}
return false;

View File

@ -6,38 +6,38 @@
<form method="post">
<h3>Pengumuman 1</h3>
<label for="kategori">Kategori: </label>
<select name="kategori">
<option value="kategori_1">Kategori 1</option>
<option value="kategori_2">Kategori 2</option>
<option value="kategori_3">Kategori 3</option>
<option value="kategori_4">Kategori 4</option>
<label for="category">Kategori: </label>
<select name="category">
<option value="1" {% if category == 1 %}selected{% endif %}>Category 1</option>
<option value="2" {% if category == 2 %}selected{% endif %}>Category 2</option>
<option value="3" {% if category == 3 %}selected{% endif %}>Category 3</option>
<option value="4" {% if category == 4 %}selected{% endif %}>Category 4</option>
</select>
<br>
<label for="konten">Konten: </label>
<textarea name="konten" rows="3" cols="30"></textarea>
<textarea name="konten" rows="3" cols="30">{{ content }}</textarea>
<br>
<label for="first-approach">Dibuat pada: </label>
<input type="text" name="first-approach" value="2017-08-28 15:20">
<label for="created_at">Dibuat pada: </label>
<input type="text" name="created_at" value={{ created_at }} disabled>
<br>
<label for="first-touch">Dibuat oleh: </label>
<input type="text" name="first-touch" value="User 1">
<label for="creator">Dibuat oleh: </label>
<input type="text" name="creator" value="User {{ creator }}" disabled>
<br>
<label for="edit">Diubah pada: </label>
<input type="text" name="edit" value="2017-08-28 15:34">
<label for="edited_at">Diubah pada: </label>
<input type="text" name="edited_at" value={{ edited_at }} disabled>
<br>
<label for="editor">Diubah oleh: </label>
<input type="text" name="editor" value="User 2">
<input type="text" name="editor" value="User {{ editor }}" disabled>
<!-- Current Timestamp -->
<input type="hidden" name="_currts" value="##CURRENT_TIMESTAMP##">