TALL-forms
  • TALL-forms
  • Installation
    • Quickstart: Artisan cmd
    • Manual installation
      • Package
      • Translations
      • Css & Theme
      • Javascript
      • Tailwind
      • Laravel Mix
      • Wrapper view
      • Laravel Jetstream/Breeze
  • Upgrade v7 to v8
    • Configuration changes
    • Component & Field changes
    • Blade view changes
    • Notification changes
    • Styling changes
  • Concept
    • Configuration
    • Validation
    • Styling
    • Icons
    • Javascript
    • Layout vs Wrapper
    • Model binding
    • Manually saving data
    • Extend Blade Components
  • Create Forms
    • Form Data
    • Form Types
      • Standard form
      • As modal
      • Without buttons
      • Fields only
      • Headless
    • Form attributes
    • Form buttons
    • Form slots
    • Form methods
    • Lifecycle hooks
    • Render a form
    • Mass generate
  • Fields
    • Declaration
    • Labels
    • Field Slots
    • Field methods
    • Custom field attributes
    • Conditional field
    • Custom view
    • Custom field
    • Custom Livewire component
    • Relations
    • Fields
      • Checkbox
      • Checkboxes
      • FileUpload
      • Honeypot
      • ImageCropper
      • Input
      • Password
      • InputArray
      • KeyVal (array)
      • Radio
      • Range
      • Repeater (array)
      • Search
      • Select & Multiselect
      • Tags
      • TagsSearch
      • Textarea
      • Trix
      • SpatieTags
    • Sponsor Fields
      • More Inputs
      • CKEditor
      • DatePicker
      • Heading
      • Markdown
      • Panels
      • SearchList
      • SelectOptGroup
      • Tabs
      • Trix, file-uploads
  • Blade components
    • Notifications
    • Label wrapper
    • Button
    • Modal blade component
    • Modal form blade component
  • Examples
    • Input examples
    • Array fields example
Powered by GitBook
On this page
  • If you want to show notification popups
  • Usage
  • In a TallFormComponent
  • In a Livewire component or Headless forms
  • Dispatch notifications
  • Color options, $type
  • Show validation errors
  • Icons

Was this helpful?

  1. Blade components

Notifications

If you want to show notification popups

Add this to your main layout file. Near the closing </body> tag, for z-index reasons.

<x-tall-notification />

Usage

In a TallFormComponent

(Already included). Form submit success, and error messages will be automatically displayed. You don't have to add anything to your TallFormComponent markup, just add the blade component to your main layout file and the rest is magic :)

In a Livewire component or Headless forms

Add the Trait

use Livewire\Component;
use Tanthammar\TallForms\Traits\Notify;

class Foo extends Component
{
    use Notify;
}

Dispatch notifications

// Via browser event
$this->notify('success', 'Record updated');
$this->notify('The form was saved successfully')

// To session
$this->withSession()->notify('success', 'Record updated');

Color options, $type

//parameters
$this->notify($type, $message, $icon, $iconcolor);

//$type => [ $color, $icon, $iconcolor ]
'success', 'green', 'saved', 'check' => ['tf-bg-success', 'check', $iconcolor],
'warning', 'orange',                 => ['tf-bg-warning', 'exclamation', $iconcolor],
'happy', 'positive'                  => ['bg-white', 'happy', 'text-green-600'],
'sad', 'negative'                    => ['bg-white', 'sad', 'text-red-600'],
'danger', 'red'                      => ['tf-bg-danger', 'warning', $iconcolor],
'info', 'blue'                       => ['tf-bg-info', 'info', $iconcolor],

//Example
$this->notify('warning', 'Server error, nothing saved');

Omitting the $type property uses the default color from the config file.

 /* Notification */
.tf-notify-bg-default {
    @apply bg-teal-400;
}

Show validation errors

The notifications are show on the second click of the submit button. On the first click, error messages below each field will be shown.

Validation errors are automatically displayed in a standard form component.

<form x-data wire:submit.prevent="saveAndStay">

    <button 
        type="submit" 
        x-on:click="$dispatch( 'replace-errors', {{ tfjs::from($errors->all()) }} )">
        Submit
    </button>

</form>

Icons

PreviousTrix, file-uploadsNextLabel wrapper

Last updated 3 years ago

Was this helpful?

If you want to show notification errors in other Livewire components add this to your submit button. For more info about the "tfjs" alias. See the file.

The notification type selects the icon. To change the design, See page.

config
Icons