yii-components

Retreving specific row from database in yii

岁酱吖の 提交于 2019-12-24 21:27:55
问题 I am working on a job site,And want to show only the jobs posted by a particular user in cgridview.My actuall aim is to authenticate the user so that only jobs posted by him/her will be visible in cgridview.I have done the following stuff,but not working. In controller: public function actionViewJob() { $user_id = Yii::app()->session['user_id']; /* For User Authentication */ if (Yii::app()->user->getId() === null) $this->redirect(array('site/login')); /* For User Authentication */ /* Have

Url parameters values with special characters are providing errors in view

本小妞迷上赌 提交于 2019-12-23 03:41:18
问题 I have edited Url manager to provide SEO friendly urls but getting problem when the url have values with special characters such as . or () or - or any other special character http://localhost/nbnd/search/city/delhi In city action var_dump($_GET); output: array(1) { ["city"]=> string(6) "delhi" } but when url is with some special character http://localhost/nbnd/search/city/north-delhi or http://localhost/nbnd/search/city/north.delhi or http://localhost/nbnd/search/city/(north)delhi In city

What is the difference between component, extension & module in Yii

自闭症网瘾萝莉.ら 提交于 2019-12-20 09:22:05
问题 I am new to Yii framework, and just came across module , extension & component inside protected folder. Can anyone please differentiate all these theoretically as well as practically also. 回答1: Components are the classes which can help you write the business logic on the basis of your models. Suppose all of your model files are using the same logic, So that logic can be written inside component instead of writing for each controller. Extensions are like the libraries, which basically are not

How do I pass a global variable in Main layout page before $content in Yii2

谁说我不能喝 提交于 2019-12-19 04:14:07
问题 I am trying to create dynamic menu in yii2 using "Nav::widget". Here is my code in menu section in main layout page: echo Nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], Trying to get the solution: Please have a look:: 1 I have created a super controller "components/Controller.php" in app: namespace app\components; use app\models\MenuPanal; class Controller extends

How to validate email and email already exist or not check, in Yii Framework?

风格不统一 提交于 2019-12-18 05:37:36
问题 How to validate email using Yii Model validation rules function code. Also how to check email exist or not using Model validation rules function in Yii. 回答1: You can set your model validations as below public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( //First parameter is your field name of table which has email value array('email', 'email','message'=>"The email isn't correct"), array('email', 'unique','message

yii. Accessing a function from a modules controller

北城余情 提交于 2019-12-13 19:12:48
问题 I have a module in my app and under its default controller it has a function called renderPageLinks which returns a array for consumption by a widget. The widget, genMenu , is called from /themes/jui/views/layouts/main.php (it generates a menu) I need to pass the data from the renderPageLinks to the widget as a value: $this->widget('pageLinkGen', array('pages' => renderPageLinks())); The problem is Yii cant find the function renderPage Links. i tried diffrent combinations of the following

component is not getting loaded in yii2 basic

大城市里の小女人 提交于 2019-12-13 04:12:05
问题 I am using yii2 basic template. I am trying create RBAC DB using database migration in yii2, I have created few tables successfully and while I am creating RBAC tables I have got different function as show below: protected function getAuthManager() { $authManager = Yii::$app->getAuthManager(); if (!$authManager instanceof DbManager) { throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.'); } return $authManager; } This

Undefined variable: yii2

假如想象 提交于 2019-12-12 04:19:05
问题 Getting error when I am trying to create dynamic form in using yii2-dynamicform. at the time of create method it is working fine but at the time of update showing the error. I have two tables one is 1.vendors & 2.vendors_more_categories Relation is 1-* between vendors & vendors_more_categories I just refereed https://github.com/wbraganca/yii2-dynamicform this link. <?php namespace app\controllers; namespace backend\controllers; use Yii; use app\models\Vendors; use app\models\VendorsSearch;

how to use one model for two different forms?

醉酒当歌 提交于 2019-12-12 01:17:35
问题 I am currently working in yii , I have designed a user module which consists user registraion , user login & change password rule . for these three process I have designed only one model i.e. user model . in this model I have defined a rule: array('email, password, bus_name, bus_type', 'required'), This rule is valid for actionRegister . but now I want to define a new required rule for actionChangePassword , array('password, conf_password', 'required'), How can I define rule for this action ?

Yii link with [ as a parameter

房东的猫 提交于 2019-12-11 20:34:12
问题 With GII I have created a list of records. I use the admin view so they are in a table view. On top of the table it is the search with a status for the records. When the status dropdown is changed I submit the form and the table gets searched. I want the default view of the admin to show only the active records so I want to create a link in the menu to this: medium/admin/?Medium[status]=active The actual link of course is medium/admin/?Medium%5Bstatus%5D=active I have tried to do it with: