Livewire: Same Component for Create and Edit Forms

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • This is a free lesson from my course "Advanced Laravel Livewire".
    Full course: laraveldaily.c...
    - - - - -
    Support the channel by checking out my products:
    - My Laravel courses: laraveldaily.c...
    - Laravel QuickAdminPanel: quickadminpane...
    - Livewire Kit Components: livewirekit.com
    - - - - -
    Other places to follow:
    - My weekly Laravel newsletter: us11.campaign-...
    - My personal Twitter: / povilaskorop

Комментарии • 27

  • @riccardotassinari2929
    @riccardotassinari2929 Год назад +6

    The mount parameter can be used for 3 different purposes:
    - passing a numerical id: the mount load the model with the given Id (edit mode)
    - passing an array: the mount initializes a new model with the given data (create mode with fields preset)
    - passing null: a new empty model is initialized

  • @Zirwahkrillz
    @Zirwahkrillz Год назад

    First one here. This is perfect as for my next project I want to forego Javascript and try Livewire fullout

  • @AnwarBarakatDev
    @AnwarBarakatDev Год назад +1

    Hello sir.
    This was perfect as for my current project.
    but after add or edit a new product I want to empty the form , i use
    $this->unset('product');
    but shows me this error
    $product must not be accesses before initilized.
    although I passed it in mount method
    public function mount(Product $product){
    $this->product = $product;
    }

  • @samiullah0011
    @samiullah0011 10 месяцев назад +1

    how to redirect to create or update component should it requires route?

  • @yungifez
    @yungifez Год назад +1

    Hey Povilas, I'm a pure livewire fan, but I'd love to ask if it would be able to manage around 10k concurrent users
    I've been assigned to create a new project

    • @LaravelDaily
      @LaravelDaily  Год назад

      I haven't tried this volume

    • @yungifez
      @yungifez Год назад

      @@LaravelDaily oh thank you

  • @salaheddinebendyab
    @salaheddinebendyab Год назад +1

    There is a problem if i have a unique item in validation ?

    • @LaravelDaily
      @LaravelDaily  Год назад

      You have to describe it differently for create and edit then, yes

  • @dodyginandjar
    @dodyginandjar Год назад

    Hai Povilas, i am a fan of livewire . I always create crud using full page component with modal for create and edit. But I have problem with datepicker in modal. I hope you make tutorial about solving it. So far , I create non-modal form if the crud need datepicker.

    • @LaravelDaily
      @LaravelDaily  Год назад +1

      I would use general date picker from HTML: input type="date"

    • @elmarzougui
      @elmarzougui Год назад

      and add this style for css file or Style tag :
      .datepicker {
      z-index: 1600 !important;
      /* has to be larger than 1050 */
      }

    • @elmarzougui
      @elmarzougui Год назад

      you can add this event inside input :
      onchange="this.dispatchEvent(new InputEvent('input'))"

    • @2509killer
      @2509killer Год назад

      the works great on modal

    • @dodyginandjar
      @dodyginandjar Год назад

      @@LaravelDaily , it's mean livewire still have a homework to fix data binding for datepicker in modal isn't it.

  • @khizer3528
    @khizer3528 Год назад

    Useful

  • @gijsbijvoets3446
    @gijsbijvoets3446 Год назад

    Is there a way to do this with livewire V3 and the new FormObjects?

    • @LaravelDaily
      @LaravelDaily  Год назад

      Yes it is possible, I'm working on a course about it, should launch next week.

    • @danielelskamp5527
      @danielelskamp5527 5 месяцев назад

      @@LaravelDaily Hi! is this course already created? I need a tutorial for V3

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 6 месяцев назад

  • @ilhampamungkas5716
    @ilhampamungkas5716 Год назад

    Its spa ? No refresh sir ?

  • @jfrosorio
    @jfrosorio Год назад

    What if you need to stay on the same page after creating a Product? How do you reset it? I'm sorry, but for me, this lesson is not 100% accurate. If you inject the model into the mount method, you cannot reset it later. In this case, the problem goes unnoticed, as the user is being redirected to another page after creating the Product.