The Krajee Switch Input widget for Yii2 based on Bootstrap Switch is great. I’ll write more about it in the near future. However, I had one major problem with a gap in the documentation – others seem to have been confused as well. When you’re using the widget in SwitchInput::RADIO mode, it’s not well documented […]
All posts by lookahead
Programming With Yii2: Exploring MVC, Forms and Layouts
As my Programming With Yii2 series continues at Tuts+, part two explores MVC, Forms and Layouts: “This tutorial will cover some of Yii’s more basic concepts related to its implementation of the MVC framework: Models, Views and Controllers. We’ll also explore layouts and customization of navigation menus and Bootstrap elements. For these examples, we’ll imagine we’re building a […]
How to Display Form Errors (the ErrorSummary)
Let’s say you’re using a validator that doesn’t correspond to a specific field and you want to display it on the form. For example, I’m using the compare validator and wish the error summary to appear on the create form. [php] <?php use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model frontend\models\Participant */ […]
How to Use the Yii2 Compare Validation
Here’s an example of how to use the Yii2 compare validator. The rules go in your model e.g. app/models/Participant.php. In this example, I’m ensuring that the participant_id and the invited_by id are not the same. I don’t want someone to be able to invite themselves. [php] public function rules() { return [ [‘participant_id’, ‘compare’,’compareAttribute’=>’invited_by’,’operator’=>’!=’,’message’=>’You cannot invite […]
How to Count ActiveDataProvider Items
Here’s how to create an ActiveDataProvider in Yii2 and get a count of records: [php] use yii\data\ActiveDataProvider; $participantProvider = new ActiveDataProvider([ ‘query’ => Participant::find()->where([‘meeting_id’=>$id]), ]); echo $participantProvider->getCount(); [/php]
Check if a record exists using ActiveRecord
In Yii2, if you’d like to check if a record exists in a table, use the following code: [php] Customer::find()->where( [ ’email’ => ‘jeff@yii2x.com’ ] )->exists(); [/php]
Web Application Development with Yii 2 and PHP
This is one of the first books written specifically for Yii2: “This book embraces the learn-by-example methodology to show you the most important features of the Yii 2 framework. Throughout the course of this book, you will build a simple real-world application; each chapter will introduce you to a new functionality and show you how […]
Krajee Yii Extensions
The folks at Krajee have a wide variety of useful Yii2 plugins. Most of them are based on the JQuery UI kit. Visit the Krajee Yii Extensions Homepage
The Yii Framework Forum
The official Yii Framework forum is an extremely useful community to ask questions and get answers. The Yii2 forum topic is a great place to get questions answered for Yii 2.0.
CraftCMS: A Yii Framework-based Content Management Platform
CraftCMS is a content management system based on the Yii Framework. It delivers an extraordinary amount of control to developers, while keeping the editing experience simple and elegant for end users. Craft makes a great alternative to WordPress for consulting firms, power users and developers. Craft is a content management system (CMS) that’s laser-focused on […]