An extended bootstrap alert and alert block widget for Yii2 (sub repo split from yii2-widgets)

Overview

Krajee Logo
yii2-widget-alert
Donate       kartikv

Stable Version Unstable Version License Total Downloads Monthly Downloads Daily Downloads

This extension contains a couple of useful widgets. The Alert widget extends the \yii\bootstrap\Alert widget with more easy styling and auto fade out options. In addition, it includes a AlertBlock widget that groups multiple \kartik\widget\Alert or kartik\widget\Growl widgets in one single block and renders them stacked vertically on the current page. You can choose the TYPE_ALERT style or the TYPE_GROWL style for your notifications. You can also set the widget to automatically read and display session flash messages (which is the default setting). Alternatively, you can setup and configure your own block of custom alerts.

NOTE: This extension is a sub repo split of yii2-widgets. The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of yii2-widgets.

Installation

The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

To install, either run

$ php composer.phar require kartik-v/yii2-widget-alert "*"

or add

"kartik-v/yii2-widget-alert": "*"

to the require section of your composer.json file.

NOTE: Using Growl is optional and it is not automatically installed with this extension. If you want to use it in your project, you need to either run

$ php composer.phar require kartik-v/yii2-widget-growl "*"

or add

"kartik-v/yii2-widget-growl": "*"

to the require section of your composer.json file.

Refer the CHANGE LOG for details on changes to various releases.

Demo

You can refer detailed documentation and demos for Alert and AlertBlock widgets on usage of the extension.

Usage

Alert

use kartik\alert\Alert;

echo Alert::widget([
	'type' => Alert::TYPE_INFO,
	'title' => 'Note',
	'titleOptions' => ['icon' => 'info-sign'],
	'body' => 'This is an informative alert'
]);

AlertBlock

use kartik\alert\AlertBlock;

echo AlertBlock::widget([
	'type' => AlertBlock::TYPE_ALERT,
	'useSessionFlash' => true
]);

License

yii2-widget-alert is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.

Comments
  • AlertBlock type growl not shown & how to setup flash messages

    AlertBlock type growl not shown & how to setup flash messages

    Prerequisites

    • [X ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
    • [X] The issue still exists against the latest master branch of yii2-widget-alert.
    • [X ] This is not an usage question. I confirm having gone through and read the documentation and demos.
    • [ X] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
    • [ X] I have attempted to find the simplest possible steps to reproduce the issue.
    • [ ] I have included a failing test as a pull request (Optional).

    Steps to reproduce the issue

    1. In controller, add this line Yii::$app->getSession()->setFlash('success', $name . Yii::t('app', ' is successfully deleted.'));

    Somehow, I cannot use array on flash message.

    1. In view, I add this line in gridview generated by johnivtn -> ajaxcrud. 'panel' => [ 'type' => 'primary', 'heading' => Html::icon('glyphicon glyphicon-list') . ' ' . Yii::t('app', '{title} listing', ['title' => $this->title, 'titleId' => strtolower($this->title)]), 'before' => AlertBlock::widget([ 'useSessionFlash' => true, 'type' => AlertBlock::TYPE_GROWL ]),

    But nothing is shown

    Expected behavior and actual behavior

    I was expecting to see the growl like notification but nothing. Actually, I can display it if it is alert not growl.

    Environment

    Browsers

    • [X] Google Chrome
    • [X] Mozilla Firefox
    • [ ] Internet Explorer
    • [ ] Safari

    Operating System

    • [X] Windows
    • [ ] Mac OS X
    • [X ] Linux
    • [ ] Mobile

    Libraries

    • jQuery version:
    • yii2-widget-alert version:

    Isolating the problem

    • [ ] This bug happens on the demos page
    • [X] The bug happens consistently across all tested browsers
    • [ ] This bug happens when using yii2-widget-alert without other plugins.

    TIA

    Daniel

    wontfix 
    opened by dadinugroho 3
  • Fatal Error - Class 'kartik\alert\Growl' not found

    Fatal Error - Class 'kartik\alert\Growl' not found

    The following code displays a fatal error:

    <?= AlertBlock::widget([
        'useSessionFlash' => true,
        'type' => AlertBlock::TYPE_GROWL
    ]) ?>
    

    kartik-v-alertblock-error

    composer configuration:

    "require": {
      "kartik-v/yii2-widgets": "*",
      "kartik-v/yii2-checkbox-x": "dev-master",
      "kartik-v/yii2-helpers": "*",
      "kartik-v/yii2-builder": "*",
      "kartik-v/yii2-grid": "*",
      "kartik-v/yii2-nav-x": "*",
      "kartik-v/yii2-dropdown-x": "*",
      "kartik-v/yii2-datecontrol": "*",
      "kartik-v/yii2-date-range": "*",
      "kartik-v/yii2-popover-x": "*",
      "kartik-v/yii2-field-range": "*",
      "kartik-v/yii2-detail-view": "*",
      "kartik-v/yii2-label-inplace": "*",
      "kartik-v/yii2-money": "*",
      "kartik-v/yii2-tabs-x": "*",
      "kartik-v/yii2-mpdf": "*"
    }
    
    bug question 
    opened by wbraganca 3
  • Growl requirement

    Growl requirement

    Prerequisites

    • [x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
    • [x ] The issue still exists against the latest master branch of yii2-widget-alert.
    • [x ] This is not an usage question. I confirm having gone through and read the documentation and demos.
    • [x ] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
    • [x ] I have attempted to find the simplest possible steps to reproduce the issue.
    • [n] I have included a failing test as a pull request (Optional).

    I was reviewing the diff from v1.1.2 to master and I noticed the composer.json was modified to require a newer version of Growl. On Growl v1.1.3 does not exist

    "require": {
        "kartik-v/yii2-widget-growl": ">=1.1.2"	        "kartik-v/yii2-widget-growl": ">=1.1.3"
    },	    },
    

    https://github.com/kartik-v/yii2-widget-alert/compare/v1.1.2...master

    https://github.com/kartik-v/yii2-widget-growl/releases

    opened by craiglondon 2
  • Install Growl automatically

    Install Growl automatically

    It seems that it's intentional that Alert Block does not install Growl automatically with itself (based on the composer.json file). I suggest installing Growl automatically to avoid the need for troubleshooting after installation. For the record, I tried installing Alert Block with composer via command line using "*" and "dev-master" and in both cases it gave the following error message:

    The class '\kartik\growl\Growl' was not found and is required for rendering Growl notifications in the alert block.
    
    Please ensure you have installed the 'yii2-widget-growl' extension. To install, you can run this console command from your application root:
    
    php composer.phar require kartik-v/yii2-widget-growl: "@dev"
    

    Eventually I installed Growl manually and it worked fine.

    question 
    opened by YasserHassan 2
  • Updating alert

    Updating alert

    I have the kartik-v/yii2-widget-alert v1.1.1 and I want to update at 1.1.4, I can’t because 1.1.4 requires kartik-v/yii2-widget-growl: >=1.1.2. But the last version of growl is 1.1.1.

    opened by gabriellaborghi 1
  • Switched bs3 widget to bs4

    Switched bs3 widget to bs4

    Scope

    This pull request includes a

    • [X] Bug fix

    Changes

    The following changes were made (this change is also documented in the change log):

    • AlertBlock class was using yii\bootstrap\Widget as dependecy instead of yii\bootstrap4\Widget
    opened by factorenergia 1
  • Error on latest update

    Error on latest update

    I got an error message like this

    {"name":"PHP Compile Error","message":"Cannot use yii\\bootstrap\\Alert as Alert because the name is already in use","code":64,"type":"yii\\base\\ErrorException","file":"/home/steve/projects/estate/vendor/kartik-v/yii2-widget-alert/src/Bs3Alert.php","line":13,"stack-trace":["#0 [internal function]: yii\\base\\ErrorHandler->handleFatalError()","#1 {main}"]}

    My app is working fine until the update. My current workaround is

    <?php

    /** * @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018 * @package yii2-widgets * @subpackage yii2-widget-alert * @version 1.1.2 */

    namespace kartik\alert;

    use Yii;

    /** * Alert widget extends the [[Alert]] widget with an easier configuration and additional styling options including * auto fade out. * * @author Kartik Visweswaran <[email protected]> * @since 1.0 */ class Bs3Alert extends \yii\bootstrap\Alert implements AlertInterface {

    `use AlertMethodsTrait;`
    

    }

    But I don't know whether this is your intention. Can you help on this Kartik?

    wontfix 
    opened by dadinugroho 1
  • alert widget not displaying in an is statement

    alert widget not displaying in an is statement

    I"m trying to implement the Array widget inside an if statement:

    if ($alert == "Duplication") { file_put_contents("/home2/nitzanha/public_html/testYair.log", "alertXXX: " . print_r($alert, true) . "\n" , FILE_APPEND); echo Alert::widget([ 'type' => Alert::TYPE_SUCCESS, 'title' => 'Well done!', 'icon' => 'glyphicon glyphicon-ok-sign', 'body' => 'You successfully read this important alert message.', 'showSeparator' => true, 'delay' => 9000 ]); file_put_contents("/home2/nitzanha/public_html/testYair.log", "YYYYYYYYYYYY: " . "\n" , FILE_APPEND); }

    As I can see in the log file the application enters the if statement but does not invokes the Alert. When moving the Alert widget outside the if statement it is being displayed.

    Please assist, Yair

    wontfix 
    opened by YairHadari 1
  • AlertBlock is not automatically closed

    AlertBlock is not automatically closed

    Prerequisites

    • [X ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
    • [X ] The issue still exists against the latest master branch of yii2-widget-alert.
    • [ ] This is not an usage question. I confirm having gone through and read the documentation and demos.
    • [ ] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
    • [ ] I have attempted to find the simplest possible steps to reproduce the issue.
    • [ ] I have included a failing test as a pull request (Optional).

    Steps to reproduce the issue

    1. In controller I add this flash: ... if ($model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Product is successfully added.')); ...
    2. In view, I add this, `
    true, 'type' => AlertBlock::TYPE_ALERT ]); ?>
    <?=
    DetailView::widget([
    

    ... `

    Expected behavior and actual behavior

    When I follow those steps, I see the flash message, but it does not disappear by itself. I want it to disappear after 2 seconds.

    Environment

    Browsers

    • [ X] Google Chrome
    • [ ] Mozilla Firefox
    • [ ] Internet Explorer
    • [ ] Safari

    Operating System

    • [X] Windows
    • [ ] Mac OS X
    • [ ] Linux
    • [ ] Mobile

    Libraries

    • jQuery version: Yii2 2.0.14dev
    • yii2-widget-alert version: latest

    Isolating the problem

    • [ ] This bug happens on the demos page
    • [ ] The bug happens consistently across all tested browsers
    • [ ] This bug happens when using yii2-widget-alert without other plugins.
    wontfix 
    opened by dadinugroho 1
  • Release v1.1.1

    Release v1.1.1

    This is not a technical question or bug report, so I allowed myself to remove the pre-set issue text.

    Dear Kartik, could you please make a new release, so we can update it through composer? I got v1.1.0 via composer and you fixed so many things meanwhile. I don't want to patch it local via copy and paste from the repo here as this surely will be bad practice.

    Thank you for your great work!

    opened by DBX12 1
  • Allow for kartik\widgets\Alert in flash messages

    Allow for kartik\widgets\Alert in flash messages

    alertSettings only applies kartik\widgets\Alert options globally. This means that a page that could get differing success flash messages would be restricted to the same title for those differing messages.

    This minor alteration allows for a full kartik\widgets\Alert options array to be received.

    Pass the array instead of string as second parameter to setFlash

    opened by andrewblake1 1
Releases(v1.1.5)
Owner
Kartik Visweswaran
Kartik Visweswaran
An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)

yii2-widget-rangeinput The RangeInput widget is a customized range slider control widget based on HTML5 range input. The widget enhances the default H

Kartik Visweswaran 19 Mar 12, 2022
Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker

Yii2 Date/Time Picker Widget Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker Demo Since this is a part of

Yevhen Terentiev 8 Mar 14, 2022
Tarantool connector for yii2 framework. Allow to use activerecord, schemas, widgets and more.

Tarantool connector for yii2 framework Tarantool connector for yii2 framework. Allow to use framework abstractions such as ActiveRecord, Schema, Table

Andrey 11 Nov 21, 2021
A Yii2 module for embedding social plugins and widgets.

yii2-social Module that enables access to social plugins for Yii Framework 2.0. It includes support for embedding plugins from the following networks

Kartik Visweswaran 92 May 29, 2022
Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

Kartik Visweswaran 38 Sep 21, 2022
Simple RBAC Manager for Yii2 (minify of yii2-admin)

Yii2 Mimin Simple RBAC Manager fo Yii 2.0. Minify of yii2-admin extension with awesome features Attention Before you install and use this extension, t

Hafid Mukhlasin 52 Sep 22, 2022
yii2-app-advanced with Twitter Bootstrap 5

Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.

Nedarta 1 Nov 5, 2021
Yii 2 widget for the Froala WYSIWYG HTML Editor.

Yii Framework Froala WYSIWYG HTML Editor Yii 2 widget for Froala Wysiwyg editor. Installation The preferred way to install this extension is through c

Froala 99 Sep 21, 2022
Extends Yii Menu widget

Extends Yii Menu widget. This widget offers a scrollspy and affixed enhanced navigation (upto 2-levels) to highlight sections and secondary sections in each page.

Kartik Visweswaran 15 Mar 12, 2022
DepDrop widget is a Yii 2 wrapper for the dependent-dropdown jQuery plugin by Krajee.

yii2-widget-depdrop The DepDrop widget is a Yii 2 wrapper for the dependent-dropdown jQuery plugin by Krajee. This plugin allows multi level dependent

Kartik Visweswaran 82 Nov 27, 2022
Web Push Notifications brought to Yii2

Web Push Notifications for Yii 2 An extension for implementing Web Push Notifications on your website in a breeze. Documentation is at docs/README.md

Mehdi Achour 12 May 19, 2022
Prometheus exporter for Yii2

yii2-prometheus Prometheus Extension for Yii 2 This extension provides a Prometheus exporter component for Yii framework 2.0 applications. This extens

Mehdi Achour 3 Oct 27, 2021
Yii2-symfonymailer - Yii 2 Symfony mailer extension.

Yii Mailer Library - Symfony Mailer Extension This extension provides a Symfony Mailer mail solution for Yii framework 2.0. For license information ch

Yii Software 28 Dec 22, 2022
Yii2 console application used to write our processors of methods to responsible to client calling.

Microservice Application Skeleton Yii2 console application used to write our processors of methods to responsible to client calling. This application

Jafaripur 0 Mar 10, 2022
Yii2 extension for format inputs based on AutoNumeric.js

Yii2 extension for format inputs based on AutoNumeric.js

extead 2 Oct 7, 2019
Pug Yii2 adapter

Yii 2 Pug (ex Jade) extension This extension provides a view renderer for Pug templates for Yii framework 2.0 applications. Support GutHub issues Inst

Pug PHP 8 Jun 17, 2022
This is Yii2 utilities

YII2-UTILITY This is Yii2 utilities. Requirements PHP >= 7.4 Curl extension for PHP7 must be enabled. Download Using Composer From your project direct

null 0 Jun 30, 2022
Alejandro Flores, Php Yii2 Emoac

Prueba Tecnica Emoac Proyecto basado en PHP con Yii2. Hecho por Alejandro Flores, Ingeniero en informática. Este proyecto consta de un CRUD de product

FlamesAlejandro 2 Sep 13, 2022
Easy integration of twitters bootstrap into symfony2

MopaBootstrapBundle MopaBootstrapBundle is a collection of code to integrate twitter's bootstrap (http://twitter.github.com/bootstrap/) as easy as pos

Philipp A. Mohrenweiser 717 Dec 15, 2022