Quantcast
Channel: Yii Framework Forum
Viewing all 18717 articles
Browse latest View live

Kartik widget has a bug!

$
0
0
Hi guys,
I just have updated my application using
composer update
. Feedback of updating was:
Updating karti-v/yii2-krajee-base(v.1.8.8=>v.1.8.9) 


I noticed following error after having updated my application:
yii\base\UnknownPropertyException: Getting unknown property: kartik\tabs\TabsX::hashVarLoadPosition in E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\Component.php:147Stack trace:#0 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-krajee-base\WidgetTrait.php(113): yii\base\Component->__get('hashVarLoadPosi...')#1 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-krajee-base\WidgetTrait.php(131): kartik\tabs\TabsX->registerPluginOptions('tabsX')#2 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-krajee-base\WidgetTrait.php(161): kartik\tabs\TabsX->getPluginScript('tabsX', 'jQuery("#w22-co...', NULL, NULL)#3 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-tabs-x\TabsX.php(388): kartik\tabs\TabsX->registerPlugin('tabsX', 'jQuery("#w22-co...')#4 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-tabs-x\TabsX.php(243): kartik\tabs\TabsX->registerAssets()#5 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-tabs-x\TabsX.php(228): kartik\tabs\TabsX->initWidget()#6 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\Widget.php(139): kartik\tabs\TabsX->run()#7 E:\xampp\htdocs\yii2_perswitch\frontend\modules\bewerber\views\bewerber\_expand.php(44): yii\base\Widget::widget(Array)#8 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\View.php(330): require('E:\\xampp\\htdocs...')#9 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\View.php(250): yii\base\View->renderPhpFile('E:\\xampp\\htdocs...', Array)#10 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\View.php(152): yii\base\View->renderFile('E:\\xampp\\htdocs...', Array, Object(frontend\modules\bewerber\controllers\BewerberController))#11 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\Controller.php(411): yii\base\View->render('_expand', Array, Object(frontend\modules\bewerber\controllers\BewerberController))#12 E:\xampp\htdocs\yii2_perswitch\frontend\modules\bewerber\views\bewerber\index.php(57): yii\base\Controller->renderPartial('_expand', Array)#13 [internal function]: yii\base\View->{closure}(Object(frontend\modules\bewerber\models\Bewerber), 1, 0, Object(kartik\grid\ExpandRowColumn))#14 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-grid\ExpandRowColumn.php(241): call_user_func(Object(Closure), Object(frontend\modules\bewerber\models\Bewerber), 1, 0, Object(kartik\grid\ExpandRowColumn))#15 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-grid\ExpandRowColumn.php(322): kartik\grid\ExpandRowColumn::parseData(Object(Closure), Object(frontend\modules\bewerber\models\Bewerber), 1, 0, Object(kartik\grid\ExpandRowColumn))#16 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\grid\DataColumn.php(233): kartik\grid\ExpandRowColumn->getDataCellValue(Object(frontend\modules\bewerber\models\Bewerber), 1, 0)#17 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-grid\ExpandRowColumn.php(360): yii\grid\DataColumn->renderDataCellContent(Object(frontend\modules\bewerber\models\Bewerber), 1, 0)#18 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\grid\GridView.php(507): kartik\grid\ExpandRowColumn->renderDataCell(Object(frontend\modules\bewerber\models\Bewerber), 1, 0)#19 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\grid\GridView.php(476): yii\grid\GridView->renderTableRow(Object(frontend\modules\bewerber\models\Bewerber), 1, 0)#20 E:\xampp\htdocs\yii2_perswitch\vendor\kartik-v\yii2-grid\GridView.php(1000): yii\grid\GridView->renderTableBody()#21 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\grid\GridView.php(347): kartik\grid\GridView->renderTableBody()#22 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\widgets\BaseListView.php(159): yii\grid\GridView->renderItems()#23 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\grid\GridView.php(316): yii\widgets\BaseListView->renderSection('{items}')#24 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\widgets\BaseListView.php(134): yii\grid\GridView->renderSection('{items}')#25 [internal function]: yii\widgets\BaseListView->yii\widgets\{closure}(Array)#26 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\widgets\BaseListView.php(137): preg_replace_callback('/{\\w+}/', Object(Closure), '



I use Git to mange my source code.
I decided to reinstall my application using a backup. After having installed backup and perform git order
git pull
,
error has been disappeared. So, I know, kartik updating causes error.
  • Any ideas, how to tell kartik this bug?
  • Any corresponding experiences available with this bug?

Smarty renderer: how to pass Yii objects to main template?

$
0
0
Dear friends!

I am trying to use Smarty view rendered with yii2. I cannot find how to use smarty template as main layout. I found some sample code, but it doesn't work.

This is 'main.tpl':
<html lang="en">
<head>
    <meta charset="{$app->charset}"/>
    <title>{$this->title|escape}</title>
    {$this->head()}
</head>
<body>	
{$this->beginBody()}
    {$content}
{$this->endBody()}
</body>
{$this->endPage()}


This is how I use it (in siteController.php):
public function actionSmarty()
{
	$this->layout = 'main.tpl';
	
	$smarty_vars['lis'] = [1,2,3,4,5];
	return $this->render('smarty.tpl', $smarty_vars);
}


This is 'smarty.tpl'
<ul>
{foreach from=$lis item=li}
    <li>{$li}</li>
{/foreach}
</ul>



This is the output:
<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8"/>
    <title></title>    
</head>
<body>	
  
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>

</ul>
</body>


So:
1) $content and $app are passed to the template and used as expected
2) $this seems to be undefined and gets ignored

Also.
Attemps to use some other objects (such as widgets) produce the following error:

Quote

SmartyCompilerException
Syntax error in template "file:/home/nginx/yii1/www/views/layouts/main.tpl" on line 14 "{Breadcrumbs::widget(['links' => $this->params['breadcrumbs'] ]}" - Unexpected "}", expected one of: "","" , ")"


I get the above error when try to use the following template:

<!DOCTYPE html>
<html lang="{Yii::$app->language}">
<head>
    <meta charset="{$app->charset}"/>
    <title>{$this->title|escape}</title>
    {$this->head()}
</head>
<body>	
{$this->beginBody()}

{Breadcrumbs::widget(['links' => $this->params['breadcrumbs'] ]}

    {$content}
{$this->endBody()}
</body>
{$this->endPage()}


It seems that I cannot simply 'copy-paste' such code from YII's php templates. What it the right syntax in this case?

Any help will be much appreciated.

Unusual Yii development? ABAP, design, SVG, CorelDraw / Inkscape. I am from Czech Republic.

$
0
0
Hello!
I was working with Yii in years 2010-2015 and I summarized my experiences in 2 manuals:



My experiences mainly come from an industrial business portal for many suppliers (written in Yii v1.1) and it's connection to SAP. Yes, I can also program in ABAP a little. I also like design (CSS, JS, CorelDraw, Inkscape icons ...) and unusual solution.

In 2016 I changed my job, but I miss Yii. Sometimes I play with v2.0 but I have no real projects so I am looking for any meaningful weekend programming.

Do you need a new web with database (orders etc.) or just a help with existing project? You can send me some typical assignment and if you are satisfied with the result, we can cooperate.

I am not a coder, but a creative programmer who wants to design the appearance and/or the code.

[Yii2] Route vs route yii1 - urlFormat path

$
0
0
Ciao Ragazzi,
sono da poco migrato a yii2 per un nuovo progetto.
Mi sono imbattuto in una gestione differente delle rotte rispetto a yii 1.

Su Yii2 le rotte del tipo:
controller/action/id/7

mi restituiscono un page not found, mentre funziona correttamente questa:
controller/action?id=7


in configurazione c'ho messo:
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => false,
            'rules' => [
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                'login' => 'user/login',
            ],
        ],


mentre in yii1 avevo:
'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'caseSensitive' => false,
            'rules' => array(
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            ),
        ),


non ho trovato molto sul formato url "path".
Qualcuno di voi ha già risolto questa problematica?

Grazie e buon lavoro a tutti.

Select2 al di fuori di una grid

$
0
0
Ciao a tutti , sono nuovo in yii2 e jquery adesso vi illustro il mio problema:
faccio presente che utilizzo widgets di Kartik.
ho 2 select2 : la prima seleziono dei dati e automaticamente aggiorno la 2 select2 mediante jquery
nel pluginEvents della select2. Diciamo semplicemente sono due select2 correlate.
Fino qui dopo numerosi tentativi sono riuscito a far funzionare le 2 select2.
Adesso però dovrei, in base alla selezione della 2 select2, aggiornare la griglia sottostante in modalità ajax.
Visto che non ho molta esperienza né in jquery né in js vorrei avere da Voi un consiglio.

Grazie

wrong route when URL contains trailing slash

$
0
0
I have to support one old project which uses Yii1. I get very strange behavior. Pretty URL is configured.

When URL doen't have a trailing slash (e.g. /about or /blog/post/5) everything goes OK (the route is correct and the correct page is displayed). But the same URLs with trailing slash (/about/ or /blog/post/5/) make a wrong route. Disregarding of url I always get the route 'main/index' and index page is displayed (not redirected to, but displayed at all URLs with trailing slash).

Any ideas?

Error pages/messages have no markup

$
0
0
Hi,

I 'inherited' an older 1.1.x Yii site and noticed that the error pages show no markup or html at all. It seems like the error pages from Yii are completely ignored.

If I call www.website.com/blabla the only response is;

Unable to resolve the request "blabla".


Without any html markup whatsoever. Just a blank white page with black text. It doesn't show the type of error either from what I noticed from other examples I found.

The header just lists it as a HTTP/1.1 200 OK


What I tried;

- Updating to latest 1.1.x version; yii-1.1.19.5790cb
- Added errorXXX.php files to themes folder /themes/<theme>/views/system/
- Added errorXXX.php files to /protected/views/system/

- Checked the SiteController.php but it has the default code;

	/**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
	    if($error=Yii::app()->errorHandler->error)
	    {
	    	if(Yii::app()->request->isAjaxRequest)
	    		echo $error['message'];
	    	else
	        	$this->render('error', $error);
	    }
	}


- Checked the main.php config but also has the default snippet

		'errorHandler' => array(
			// use 'site/error' action to display errors
            'errorAction' => 'site/error',
        ),



I tried various suggestions posted in other topics/pages I found across the web but no luck as of yet. I'm kinda at a loss here.

Does anyone have any idea where to look and/or what to change?

Raspina cms


[Extension] yii2-search

beforeSave() edit the record before saving

$
0
0
data in the birthday field is entered manually and i need to save the last 4 characters from the 10 entered characters to the database, but i can not edit the record before saving. Please help!!
class SignupForm extends Model
{

    public $username;
    public $email;
    public $password;
    public $birthday;
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['username', 'trim'],
            ['username', 'required'],
            ['username', 'unique', 'targetClass' => '\app\models\User', 'message' => 'This username has already been taken.'],
            ['username', 'string', 'min' => 2, 'max' => 255],
            ['email', 'trim'],
            ['email', 'required'],
            ['email', 'email'],
            ['email', 'string', 'max' => 255],
            ['email', 'unique', 'targetClass' => '\app\models\User', 'message' => 'This email address has already been taken.'],
//            ['password', 'required'],
//            ['password', 'string', 'min' => 3],
            ['birthday', 'required'],
            ['birthday', 'string', 'min' => 10, 'max' => 10]
        ];
    }

    /**
     * Signs user up.
     *
     * @return User|null the saved model or null if saving fails
     */
    public function signup()
    {

        if (!$this->validate()) {
            return null;
        }

        $user = new User();
        $user->username = $this->username;
        $user->email = $this->email;
        $user->setPassword($this->birthday);
        $user->generateAuthKey();
        return $user->save() ? $user : null;
    }

    public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            $this->birthday = substr('$birthday', 6,4);
            return true;
        } else {
            return false;
        }
    }


}

Important note about Bower and the asset plugin

$
0
0
Bower has changed their registry URL some time ago and has now announced to deprecate the old URL. Old registry will be disabled next Wednesday. In order for your work not to be affected make sure to update your composer asset plugin to the latest version:

composer global require "fxp/composer-asset-plugin:^1.4.2"


Versions prior to 1.4.2 use the https://bower.herokuapp.com/packages URL for fetching bower packages, which currently redirects to https://registry.bower.io/packages. This URL will be disabled on Wednesday, October 26, 2017 according to the Bower announcement so asset plugin versions prior to 1.4.2 will not be able to fetch any packages.

There is also a news announcement about this.

Visualizzare Sql da ActiveRecord

$
0
0
Ciao a tutti è possibile visualizzare l' SQl di un activerecord ottenuto tramite funzioni all(), one(),....
per poter effettuare test?
grazie

Erro ao listar

$
0
0
Galera é o seguinte,

sistema de cadastro com banco funcionando normal, inclusive com os relacionamentos, porem quando tento trazer para a view a busca ele só retorna inteiros. : IMG-20171019-WA0009.jpg na imagem acima deixei o código que fiz para trazer do banco os dados, creio que falta algum parâmetro para puxar do banco os departamentos : IMG-20171019-WA0006.jpg conforme imagem acima.

: IMG-20171019-WA0005.jpg
aqui é o search

: IMG-20171019-WA0007.jpg
aqui tem a config do model

favor, uma luz!

ServiTron.com - Hotels mini bar consumption software

$
0
0
Hotels mini bar consumption with IVR support

https://servitron.com
- Powered by Yii2 (advanced template)
- Multilanguage
- With IVR (Intelligent Voice Response) integration using Asterisk
- Running on CentOS 7.3
- Closed source

- Used to control and report Mini bar consumption and product inventory.
- Users can report consumption either via IVR using Asterisk as PBX while all logic is implemented using Yii's console via Asterisk AGI (Asterisk Gateway Interface) or using the application's frontend.
- It also communicates with the hotel's PMS (Property Management System) via TCP or in some cases via RS232 in order to charge guests as soon as the consumption is reported.
- All reports and statistics can be exported to PDF.
- Support multiple accounts (hotels).

error composer

$
0
0
buenos tardes,

quiero instalar el adminlte en yii2 pero me sale el siquiente error:

problem 1 -sebastian/recursion-context 3.0.0 requires php ^7.0 -> your php version <5.6.3 does not satisfy that requirement

installation failed reverting ./composer.json to its original content

este es mi composer.json

"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Project Template",
"keywords": ["yii2", "framework", "advanced", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0.6",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"2amigos/yii2-date-picker-widget" : "~1.0",
"phpoffice/phpexcel": "dev-develop"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",
"yiisoft/yii2-gii": "~2.0.0",
"yiisoft/yii2-faker": "~2.0.0",

"codeception/base": "^2.2.3",
"codeception/verify": "~0.3.1"
},
"config": {
"process-timeout": 1800,
"fxp-asset":{
"installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
}

agradeceria su gran ayuda

problem z instalacją yii2

$
0
0
Witam

Mam problem z Yii2, instalowałem wg dokumentacji:
https://github.com/phundament/docs/blob/master/6-tutorials/installation-composer.md

composer global require "fxp/composer-asset-plugin:1.1.*"
composer create-project --stability=beta phundament/app myapp


cd myapp
cp .env-dist .env
edit .env


./yii migrate --interactive=0
./yii app/setup-admin-user --interactive=0


Open http://path-to-app/web or http://path-to-app/web?r=admin in your browser.

Jak wchodzę w localhost/myapp/web to przekierowuje mnie od razu do localhost/en i wyświetla komunikat:
The requested URL /en was not found on this server.

Proszę o pomoc

Google reCAPTCHA V2 widget for Yii 1

$
0
0
Google reCAPTCHA V2 widget for Yii 1

Installation

Get API key from Google.www.google.com/recaptcha/admin#createsite
Copy Source Folder to Extensions
Set Public Key (siteKey) and Private Key (secret) in params or components
Add SReCaptchaValidator in your model:
public $reCaptcha;
//...

public function rules()
{
  return [
      // ...
      // secret is required
      ['reCaptcha', 'application.extensions.reCaptcha2.SReCaptchaValidator', 'secret' => Yii::app()->params['reCaptcha2PrivateKey'],'message' => 'The verification code is incorrect.']
      // ...
  ];
}

Usage

If you want render ReCaptcha use simple code in your view file:
Yii::import('application.extensions.reCaptcha2.SReCaptcha');
$this->widget('SReCaptcha',
  [
        'name' => 'reCaptcha', //is requred
        'siteKey' => Yii::app()->params['reCaptcha2PublicKey'], //is requred
        'widgetOptions' => ['class' => 'col-lg-3'],
        'theme' => SReCaptcha::THEME_DARK,
        'size' => SReCaptcha::SIZE_COMPACT,
        'jsCallback' => 'console.log("reCaptcha is ready!");console.log(response);',
        'jsExpiredCallback' => 'console.log("reCaptcha is expired!");'
  ]
);

If you want render ReCaptcha in active form:
$form->widget('application.extensions.reCaptcha2.SReCaptcha',
    [
        'name' => 'reCaptcha', //is requred
        'siteKey' => Yii::app()->params['reCaptcha2PublicKey'], //is requred
        'model' => $model,
        //'attribute' => 'reCaptcha' //if we use model name equal attribute or customize attribute
    ]
);

If you use several forms or ajax and need multi render ReCaptchas:
<div id="reCaptchaLogin"></div>
<div id="reCaptchaReg"></div>

$this->widget('application.extensions.reCaptcha2.SReCaptcha',
    [
        'siteKey' => Yii::app()->params['reCaptcha2PublicKey'],
        'render' => [
            'reCaptchaLogin' => [
                'callback' => 'console.log("#reCaptchaLogin is ready!");',
                'theme' => 'dark',
                'expired-callback' => 'console.log("#reCaptchaLogin is expired!");'
            ],
            'reCaptchaReg' => [
                'size' => 'compact',
                'callback' => 'console.log("#reCaptchaReg is ready!");console.log(response);',
            ]
        ],
    ]
);

More information:
developers.google.com/recaptcha/docs/display.
developers.google.com/recaptcha/docs/verify.
github.com/cheerymagicsoftware/Yii1ReCaptcha2.

Javascript issue "checkInQuery is not defined" for jquery.selgridview.js

$
0
0
Hey friends,
Today I found this JavaScript error while working with selgridview widget for YII v1.
It is typo mistake in your jquery.selgridview.js file at line 106.
Change checkInQuery to checkedInQuery; and evrything works fine.

Minimal working framework package?

$
0
0
Hello. I wonder how can I minimize the framework bundle. The main question is about vendor directory. Even basic app template contains over 20 vendors folders there. Are they all really necessary for the framework to work?

When I try to delete some folders from there I get an error from composer autoload script where all the vendors are listed.

May I just have yii-soft folder without any other "vendors"? (or at least minimize their number).

How to set up user-defined interface language for all site (i18n)

$
0
0
// controller
/**
 * @return \yii\web\Response
 * @throws NotFoundHttpException
 */
public function actionChangeLanguage()
{
    $language = Yii::$app->request->post('language');
    $supportedLanguages = Yii::$app->params['supportedLanguages'];

    if (!in_array($language, $supportedLanguages)) {
        throw new NotFoundHttpException;
    }

    Yii::$app->language = $language;

    $languageCookie = new Cookie([
        'name' => 'language',
        'value' => $language,
        'expire' => time() + 60 * 60 * 24 * 30,
    ]);

    Yii::$app->response->cookies->add($languageCookie);

    return $this->redirect(Yii::$app->request->referrer);
}

// params
return [
    // Add / remove languages here. The whole system will work.
    // Format for locale installation: ll-CC, where ll is a two-letter or three-letter language code lowercase
    // in accordance with ISO-639 (http://www.loc.gov/standards/iso639-2/),
    // and CC is the country code in accordance with the standard ISO-3166 (https://www.iso.org/obp/ui/#search/code/).
    'supportedLanguages' => [
        'ru-RU' => 'ru-RU',
        'en-US' => 'en-US',
    ],
];

// bootstrapper
namespace frontend\bootstrappers;

use yii\base\BootstrapInterface;
use yii\base\Object;

class LanguageSetter extends Object implements BootstrapInterface
{
    public function bootstrap($app)
    {
        $preferredLanguage = isset($app->request->cookies['language'])
            ? (string)$app->request->cookies['language']
            : null;

        if (empty($preferredLanguage)) {
            $preferredLanguage = $app->request->getPreferredLanguage(\Yii::$app->params['supportedLanguages']);
        }

        $app->language = $preferredLanguage;
    }
}

// config
return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => [
        'log',
        frontend\bootstrappers\LanguageSetter::className(),
    ]
];
Viewing all 18717 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>