Displaying 21-30 of 276 results.
Resolved: Yii 1.1 CGridView Error 500 Trying to get property of non-object
posted by admin on April 8, 2016
I have CGridView with relation

admin.php in Media view

<?php $this->widget('zii.widgets.grid.CGridView', array(
'name' => 'gallery_id',
'value' => '$data->gallery->name',
'filter' => CHtml::listData(Gallery::model()->findAll(), 'id', 'name'),
)); ?>

Gallery.php Model

class Gallery extends CActiveRecord
. . .
public function relations()
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::HAS_MANY, 'Media', 'gallery_id'),
. . .

Media.php Model

class Media extends CActiveRecord

public function relations()
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::BELONGS_TO, 'Gallery', 'gallery_id'),

I see this error

Error 500
Trying to get property of non-object

Error in line

'value' => '$data->gallery->name',
Read more
Resolved: Yii sum criteria select condition
posted by admin on April 15, 2016
I try to count my views sum count, by this way

$criteria=new CDbCriteria;
$criteria->select='SUM(visits) as SUMvisits';
$sBalance = Views::model()->find($criteria)->getAttribute('SUMvisits');

Something like this, but it is not workingRead more
Wiki: Yii2 beforeSave() and afterSave()wiki
posted by admin on February 22, 2017
Wonderful methods beforeSave () and afterSave () in Yii2 help us to solve various problems, for example, you want before saving the database to change the date format, or save the log action. But not everyone knows how to inherit them.

Let's start with a simple afterSave():

public function afterSave($insert, $changedAttributes){
parent::afterSave($insert, $changedAttributes);
//... to do

There is nothing complicated, we simply pass to the parent method all the same settings and run it, and then do everything we needed.

Now beforeSave():

public function beforeSave($insert)
if (parent::beforeSave($insert)) {
//... to do
return true;
return false;

All the practical as well as with afterSave() method, except that we need to return the result of the parent method, otherwise we when calling $model->save() will get false, and our model will not be saved, nor do we we will receive no errors. Remember this moment.

Yii1 The principle is the same, only the parameters are not transferred there.Read more
Resolved: Yii 1.1 CDetailView visibility, check condition if else
posted by admin on March 6, 2016
I have CDetailView, and I want to check some condition and if condition is true, allow row output, else hide row from detailview table

$this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => array(
'label' => Yii::t('translation', 'About'),
'type' => 'raw',
'value' => $model->about,

How to write condition to about?Read more
Wiki: Laravel 5.2 install IDE helper for NetBeans (Namespaces, Classes and all libraries)wiki
posted by admin on August 12, 2016
Helper Source laravel-ide-helper GITHUB Official

CMD Terminal
Open CMD terminal
Go to your Laravel project root directory by

cd C:\xampp\htdocs\laravel.dev

Require this package with composer using the following command:

composer require barryvdh/laravel-ide-helper

After updating composer, add the service provider to the providers array in config/app.php


Automatic phpDoc generation for Laravel Facades
You can now re-generate the docs yourself (for future updates)

php artisan ide-helper:generate

Note: bootstrap/compiled.php has to be cleared first, so run

php artisan clear-compiled

before generating (and

php artisan optimize


You can configure your composer.json to do this after each commit:
You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for --helpers or --sublime.

php artisan vendor: publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config

Restart NetBeans IDERead more
Wiki: Yii2 basic include css js files to module views layout main from module assetswiki
posted by admin on March 1, 2017
Module Information
Module Admin


Create Module ASSETS in Web folder with content


Create Module views layouts


Change your Module and change layouts way in your config web.php

$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['gii'],
'modules' => [
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['', '::1', '192.168.0.*', ''] // adjust this to your needs
'admin' => [
'class' => 'app\modules\admin\Module',
// the layout that should be applied for views within this module
'layout' => 'main',

Create Module new assets settings class
In modules/admin directory create file AdminAsset.php with content

namespace app\modules\admin;
use yii\web\AssetBundle;

class AdminAsset extends AssetBundle
public $sourcePath = '@app/modules/admin/web/assets';
public $css = [
public $depends = [

Go to your Admin Module layouts/main.php and replace your assets registration and namespace with

use app\modules\admin\AdminAsset;

Read more
Resolved: markItUp. BBCode Parser with emotions smiles
posted by admin on December 25, 2015
altI want to convert convert markItUp BBCode to HTML tags.
I have smiles too.Read more
Resolved: Stop loading jquery library from assets folder in Yii
posted by admin on January 24, 2016
I had problem in my app that made it slow , after checked firebug I noted that jquery-ui loaded twice first from google.com and second from assets folder ("232kb") .

How to force it to load from google.com, or localhost, or jquery.com without assets version ?Read more
Resolved: Composer Ubuntu installation and errors
posted by admin on January 18, 2017
I am trying to install composer by that way and get some errors.
Step 1: Ensure the Curl dependency is installed.

sudo apt-get -y install curl

Step 2: Download the Composer installer and pass it to php.

sudo curl -sS https://getcomposer.org/installer | php

My error in this step:

The program 'php' can be found in the following packages:
* php7.0-cli
* hhvm
Try: sudo apt install <selected package>
curl: (23) Failed writing body (0 != 16133)
Read more
Resolved: Yii captcha does not work first time
posted by admin on December 22, 2015
I am trying to create register form where I used captcha. I have enabled ejax validation. But the there is a problem, captcha does not work first time. When I generate new captcha code, that works. My code is:

In model,

public $verifyCode;

public function rules()
return array(
array('verifyCode','captcha','allowEmpty'=>!CCaptcha::checkRequirements(), 'on'=>'registration'),

array('id, first_name,last_name, email, username, password, password_repeat, user_type, keystring, status, logo_url, last_login_time, create_time, update_time, validation', 'safe', 'on'=>'search'),

In controller:

public function actions()
return array(

In view:

<?php if(CCaptcha::checkRequirements()): ?>
<div class="row">
<?php echo $form->labelEx($model,'verifyCode'); ?>
<?php $this->widget('CCaptcha', array('captchaAction'=>'user/captcha')); ?>
<div class="formfieldarea">
<div class="form-text"></div>
<div class="form-field">
<?php echo $form->textField($model,'verifyCode'); ?>
<div class="hint">Please enter the letters as shown.

Letters are not case-sensitive.</div>
<?php echo $form->error($model,'verifyCode'); ?>
<?php endif; ?>

I have searched in google a lot to find the solution. But did not find. Please help someone.:(Read more