Yii

Hide label for input field

℡╲_俬逩灬. 提交于 2019-12-20 16:21:47
问题 I am trying to hide the label for a specific field in _form.php without success. I have tried couple of variation like, but none is working: <?= $form->field($model, 'sample_text')->textArea('label'=>false) ?> and alternate code: <?= $form->field($model, 'sample_text')->textArea('label'=>'') ?> What is the right approach to hide a label? 回答1: Ok, I found the solution. <?= $form->field($model, 'sample_text')->textArea()->label(false) ?> 回答2: Or you can modify template value for particular

Theming and layout in yii framework

て烟熏妆下的殇ゞ 提交于 2019-12-20 12:39:51
问题 I am a newbie in Yii Framework and creating a CRM which is module based. Using different tutorials I am able to create my own theme, but now I am stucked at one point. In my theme, the upper <nav> and left <nav> remains the same throughout the app, until user is logged in. That's why I made it a part of my main.php , but in the login page there are no buttons to show, just simple login form with 2 textfields . How can I implement this form in my application using custom themes? I have tried

database migration in Yii

廉价感情. 提交于 2019-12-20 11:29:14
问题 In order to doing migration in Yii I used this lines <?php class m110714_122129_users extends CDbMigration { public function up() { $this-> createTable('{{users}}',array( 'id' => 'pk', 'username' => 'VARCHAR (80) NOT NULL', 'password' => 'VARCHAR (80) NOT NULL', 'email' => 'VARCHAR (128) NOT NULL', 'activekey' => 'VARCHAR (128) NOT NULL DEFAULT \'\'', 'createtime' => 'INTEGER (10) NOT NULL DEFAULT \'0\' ', 'lastvisit' => 'INTEGER (10) NOT NULL DEFAULT \'0\' ', 'superuser' => 'INTEGER (1) NOT

Sorting CListView in yii

一个人想着一个人 提交于 2019-12-20 10:42:11
问题 Please consider this: class User extends CActiveRecord { ... public function relations() { return array( ... 'articleCount' => array(self::STAT, 'Article', 'userid'), ... ); } ... } Now, I need to create a $dataProvider = new CActiveDataProvider(...) to feed a CListView widget to which I want add articleCount to the property sortableAttributes so that I can sort User records according to the number of articles the user is the author for. What are the most convenient method? what are the other

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

Generate Yii translation message files

烈酒焚心 提交于 2019-12-20 09:04:19
问题 I am interested to know is there a script or otherway available to collect and generate Yii translation messages in a controller/project Eg. If I have the following codes in a controller Yii::t('blog', 'Your name'); Yii::t('category', 'Category name'); It should generate English translation message files as blog.php and category.php with above strings in messages directory. Please let me know if somebody knows a way. Thanks 回答1: There's no need to reinvent the wheel. You can use yiic for that

show logout button along with the name of user after successfull login

余生长醉 提交于 2019-12-20 07:41:19
问题 I am a yiibie, and i am stuck at a point. I have three roles in my project. 1.Admin. 2.Owner 3. Authenticated User. I have a header and a footer widget.In header widget which is the top section has a signup and login link. i want to show my user name and a logout link after his successful login. I do not want to make another widget. i Know the logic, we can use if else. If a user has been logged in, show his name and logout link at the top section(header widget). else if he is a normal user

Property “tablename.title” is not defined

点点圈 提交于 2019-12-20 07:18:52
问题 i am Yiibie. What i am trying to do is to upload image(photo), and path entry in database with update functionality. i have followed this link `http://www.yiiframework.com/wiki/349/how-to-upload-image-photo-and-path-entry-in-database-with-update-functionality/#hh0. I have followed everything of this link but getting an error which is "Property 'Ngo.title' is not defined" upon clicking submit button. Down is the code what i have been trying to do. This is the code for the NgoController <?php

Yii Index View Data Rendering With Condition

假如想象 提交于 2019-12-20 07:10:52
问题 I am new to yii framework i have created an yii web application with one module . Now my question is i have added an sample data into my module in my module i have an columns name,dept and and active ,i want to render the data in the grid view only the data where active=0 , Can anyone help me how to change the data rendering query and how to add the condition <div class="block"> <div class="content"> <h2 class="title">Users's details</h2> <div class="inner"> <?php $this->widget('zii.widgets

how to convert this query in yii framework model

被刻印的时光 ゝ 提交于 2019-12-20 06:26:33
问题 SELECT u.id, u.username, u.score, (SELECT COUNT(ownerId) FROM post p WHERE p.ownerId = u.id) AS totalPost FROM users u ORDER BY u.score DESC, totalPost DESC LIMIT 10 回答1: $sql = "SELECT u.id, u.username, u.score, ". "(SELECT COUNT(ownerId) FROM post p WHERE p.ownerId = u.id) AS totalPost ". "FROM users u ". "ORDER BY u.score DESC, totalPost DESC ". "LIMIT 10"; $command=Yii::app()->db->createCommand($sql); $results=$command->query(); or if you have a User model (I think this will work - I didn