Modals is dynamic popup windows that will lay above the sites content.

Message modal

Will open up a modal message view.

$this->provider->responder()->message("Form has been sent!");

Error modal

Will open up a error modal message view. The key difference with the above message view is that this view also has the class error that will turn the text red if using built in CSS or tailwind.

$this->provider->responder()->error("You have an error in you form.");

Custom modal

You can also very easily create custom modals by binding existing or your custom views to them.

Set modal view

$item = $this->responder()->setView("modal", [
    "type" => "opener",

The first argument is the expected view, and the second argument is the modal config type. You can choose between "opener," "message," "ok," and "confirm." You probably want the "opener" option.

Now the modal view will be loaded, but it is empty, so we need to append some content to it. We do this by appending existing views.

Append view to modal

Now, let's append a view/component to the modal view by utilizing the $item variable from the above example. Add the code below directly under the setView modal code.

// Add ingress view to modal
$item->item("ingress", [
    "headline" => "Contact us",
    "content" => "Lorem ipsum dolor"

You can of cource utilze any view and multiple views.

Last updated