The form is not submitted in the modal.
The problem is that when reading the form it doesn’t recognize the livewire parameters,because its not calling the method “addNote”.
When submit the page just refreshes.
Тhis is the form witch different livewire component.
<div class="col-md-12">
<h5 class="font-weight-bolder text-primary">Add Note</h5>
<form wire:submit.prevent="addNote">
<div class="form-group">
<label for="noteMessage">Message</label>
<textarea class="form-control" id="noteMessage" wire:model.defer="noteMessage" rows="3" placeholder="Write your note"></textarea>
</div>
<button type="submit" data-bs-dismiss="modal" class="btn bg-gradient-primary mt-3">Submit</button>
</form>
</div>
</div>
and the modal:
<!-- module messages -->
<div class="row">
<div class="col-md-12 text-center">
@if($instructor_note)
<h5 class="font-weight-bolder text-primary">{{$instructor_note}}</h5>
@else
<h5 class="font-weight-bolder text-primary">No added notes</h5>
@endif
</div>
</div>
<!-- module messages end -->
<!-- instructor note input -->
@if(auth()->user()->instructor_approval !== null)
<livewire:instructor-notes :course_schedule="$course_schedule">
@endif
<!-- instructor note input end -->
</div>
<div class="modal-footer">
<button type="button" class="btn bg-gradient-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
the modal component:
namespace AppHttpLivewire;
use AppEventsopenModalGlobal;
use AppModelsCourseSchedule;
use AppModelsInstructorNote;
use LivewireComponent;
class Schedule extends Component
{
public $componentName = 'Schedule';
public string $events = '';
public int $course_id = 0;
private $schedule = '';
protected $listeners = ['echo:calendar,CalendarBroadcast' => 'refreshCalendar'];
public $course_schedule;
public $noteMessage;
//function for opening the schedule info modal
public function openScheduleInfoModal($course_schedule_id)
{
$course_schedule = CourseSchedule::find($course_schedule_id);
$instructor_note = InstructorNote::where('course_schedule_id', '=', $course_schedule_id)->value('note');
$this->refreshCalendar();
$modalId = 'scheduleInfoModal';
$html = view('modals.schedule-info')->with('course_schedule', $course_schedule)->with('instructor_note', $instructor_note)->render();
$session_id = session()->getId();
event(new openModalGlobal($html, $modalId, $session_id, $this->course_id > 0 ? 'course/' . $this->course_id : 'dashboard'));
}
}
The only thing I’ve tried is to put the form in a different component hoping it won’t conflict with the modal.
But without success
New contributor
new_with_js is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.