Home > Blockchain >  Passing data from controller to header in modal
Passing data from controller to header in modal

Time:03-17

Please help me..

I want to pass some text from controller to modal in header tag..

This is what I want to send to header at modal from controller's method:

$this->labelFormTambah = "Edit Data Donatur";

And this is the attribute of the header that I want to send the data above:

<h3  id="labelFormTambah" wire:model="labelFormTambah">

Sadly that doesn't work.

Any data sent from the same method to the same modal in input tags, is perfectly working.

Where is my mistake?

CodePudding user response:

I have a suggestion.

Your controller should look something like this:

public function edit(){
    //since you know the value of $this->labelFormTambah you can just pass it as an argument instead of creating a variable name first
    return view("edit.page",["lableForm" => "Edit Data Donatur"])
}

And then in your edit page your modal header should be like this:

<h3  id="labelFormTambah" wire:model="labelFormTambah">{{$labelForm}}</h3> //the value in the double curly braces comes from the argument you've passed in your controller

And that will display your $this->lableFormTambah value that you returned along with your view as a value in your modal header tag

  • Related