Playing Next Lesson In
seconds

Let's Learn AdonisJS 6 #11.5

How To Use One Form to Create or Edit Movies

In This Lesson

We'll learn how we can merge our create form and edit form together into a create or edit form. We'll conditionally determine whether we'll be creating or editing based on our movie value and use EdgeJS features to simplify the process

Created by
@tomgobich
Published

🕰️ Chapters
00:00 - Making the Create or Edit Page
02:10 - Setting Input Values for Create or Edit
03:34 - Swapping In & Testing Our Page
04:24 - Deleting Our Create and Edit Pages
04:31 - Testing Our Create or Edit Page

Join the Discussion 2 comments

Create a free account to join in on the discussion
  1. @adun

    Since releasedAt is nullable in the Movie model, the Edit action fails when a movie has no release date, raising:

    Error: Cannot read properties of null (reading 'toFormat')

    A small defensive fix would be to make the access optional increateOrEdit.edgefile:

    // replace
        value: movie?.releasedAt.toFormat('yyyy-MM-dd')
    // with
        value: movie?.releasedAt?.toFormat('yyyy-MM-dd')
    Copied!

    1
    1. Responding to adun
      @tomgobich

      Good catch, thanks for sharing @adun! Apologies I missed that!!

      1