Skip to content

Commit

Permalink
Replace Create Edit to Form for single use
Browse files Browse the repository at this point in the history
  • Loading branch information
chiqors committed Jun 14, 2020
1 parent 4974878 commit 201f50f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/Controllers/Http/PostsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class PostsController {
}

public async create({ view }: HttpContextContract) {
return view.render('posts.create')
return view.render('posts.form')
}

public async store({ request, response }: HttpContextContract) {
Expand All @@ -26,7 +26,7 @@ export default class PostsController {

public async edit({ params, view }: HttpContextContract) {
const post = await Post.find(params.id)
return view.render('posts.edit', { post })
return view.render('posts.form', { post })
}

public async update({ params, request, response }: HttpContextContract) {
Expand Down
17 changes: 0 additions & 17 deletions resources/views/posts/create.edge

This file was deleted.

17 changes: 0 additions & 17 deletions resources/views/posts/edit.edge

This file was deleted.

17 changes: 17 additions & 0 deletions resources/views/posts/form.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@layout('app')

@section('page')
<form action="{{ post ? route('PostsController.update', { params: { id: post.id } }) : route('PostsController.store') }}" method="POST">
<div>
<label for="title">Title</label>
<input name="title" type="text" value="{{ post ? post.title : '' }}">
</div>

<div>
<label for="content">Content</label>
<textarea name="content">{{ post ? post.content : '' }}</textarea>
</div>

<button type="submit">{{ post ? 'Update' : 'Create' }}</button>
</form>
@endsection

0 comments on commit 201f50f

Please sign in to comment.