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

Multiples row insert

$
0
0
Buenas tardes, primero que nada un saludo y gracias por su acostumbrada ayuda...

Estoy trabajando en un Modulo de reclamo, en el que muestra un formulario el cual pide N cantidad de datos, y si este va a realizar múltiples reclamos de código genera una fila nueva y así sucesivamente...

el asunto es que en proyecto anteriores y en programación sin frameworks yo realizaba esta función de la siguiente forma.

<from action="xxx.xxx" methodo="POST">
<input name ="id[]" >
</from>


y desde mi php hacia un count a la variable que recibía.

count($_POST["id"]);


y luego generaba un ciclo for para guardar con un insert.

pero creo que esto no es opción para YII 1.1.x

Alguno de ustedes conoce alguna forma rápida en la que pueda hacer uso a la funciones de YII y su MVC.

Espero haberme explicado con claridad y recibir de su apoyo.

saludos,

Captura del Formulario.
: Captura.PNG

Beginners Guide To Yii2 RestAPI

$
0
0
So you want to setup a Rest Application Using Yii2

What is REST

Basically you input something like
yousite/companies/index 


into a url and get back
[ 'name':'wesvault','name':'yii2 company']


that is really all there is to REST. It gets things.

Step 1:

Install Yii2 Framework. Lots of examples on how to do this. I recommend the advanced template or the modified yii2-practical template

Step 2:

Create a Model.
Go to gii , model generator and input your table "companies" at

common\models\companies


Step 3:

Create A controller

Same thing in Gii, controller generator

name: CompaniesController
path: frontend\controller\CompaniesController

Step 4:
Edit this controller to use the restful add-ons



namespace frontend\controllers;

use yii\rest\ActiveController;    <--- This says use the rest version of activecontroller 

class ContactsController extends ActiveController   <--- This extends Activecontroller 
{
    
	public $modelClass = 'common\models\Contacts';  <-- you need to tell it which model class
	


}


Step 5:
Ok now it knows to return a restful action, but how does it handle the incoming url instead of a normal web display.
For this you need to setup the Url Manager, find it in

common/config/main.php


Add this to the Url Manager

 'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing'=> true,   <--- It must match GET , POST etc etc (any one of the rules) 
			
            'showScriptName' => false,
			'rules'=> [
				['class'=>'yii\rest\UrlRule',  <-- this is the standard rule class
				 'controller'=>'contacts',     <-- which controller   "contacts/{rule}"        
				 'extraPatterns'=>['GET hello' => 'hello',]   <-- I add a custom rule  
				 
				 ]
			]
		],


Step 6:
Give it a test.
Download POSTMAN or http://restclient.net/ for your browser then enter the url GET : yousite/contacts
you should see a return of some JSON objects. That's basically it.

Step 7: (custom actions rules)
Ok you have whatever yii2 gives you. But what if you want another rule action like say hello. Above you see I added the rule pattern

Just go to your controller and add in that action normally

public function actionHello()
	{
        return 'hello';
	}


Fire up your browser and try get yoursite/companies/hello. You should see "hello" come back.

Crear graficas con eventos en Highcharts + PHP + MySQL + Yii2

$
0
0
hola buenas tardes,

quiero crear unos reportes con graficas ya cree mi base de datos y tengo ya mis datos en las tablas en yii2, me gustaria crear unos reportes dinamicos en tiempo real que se precione un boton y le arroje las graficas a uno, alguien que tenga idea de este tema y me pueda ayudar, se lo agradeceria muhcho.

download file

$
0
0
Mohon bantuan,, bagaimana cara untuk download file dari server...
saya coba error terus,, file yang sudah terdownload tidak bisa dibuka, corrupt file...

'file jpeg'

[Extension] yii2-tinify

Forgot Password Issue

$
0
0
Hi all,
I have an issue with my attempt of successfully creating a ForgotPassword login page reachable from my index.
The project I'm working in has pass through so many programmers so I'm having difficulties trying to figure out which part of the code is preventing me to have success.
Whenever I try to insert a redirecting from the login.php I fail: infact the recuperapassword view (forgotpassword in english) is visible ONLY IF you are logged in (pretty useless). It's like if all the views are blocked if you are NOT logged in. What should I do? Any kind of suggestions and hints are well accepted.
Thank you in advance
login.php
 login.php (1.45K)
: 1
recuperapassword.php
 recuperapassword.php (17bytes)
: 2
SiteController.php
 SiteController.php (3.86K)
: 1
UserController.php
 UserController.php (4.59K)
: 0
User.php
 User.php (4.71K)
: 0

Widget-Dataprovider-Count same rows

$
0
0
Hi Yii Masters!

I have a problem, what i cant solve it. I tried search the solution, but i cant find it (of course that is my mistakes ^^').
So I have a Datagridview from $model, which show a Cars and Owners.
I want counting the same rows (see below the sample what i want)



<?php
$this->widget('application.extensions.NPager.NGridView', array(
'id' => 'Car-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'ajaxUrl' => $this->ajaxUrl,

'cssFile' => Yii::app()->baseUrl . '/css/gridview/styles.css',
'template' => '{summary}{pagerlist}{pager}{items}{pager}',
'pagerlist' => array(
'8' => '8',
'10' => '10',
'25' => '25',
'50' => '50',
'100' => '100',
),
'textItemsPerPage' => 'per side',
'columns' => array(
array(
'name' => 'Owner',
'header' => 'Owner',
'type' => 'raw',
'filter' => CHtml::activeTextField($model, 'searchid', array('id'=>'Owner_tb'),
),

array(
'name' => 'Car',
'header' => 'Car',
'value' => '(is_object($data->car),
'type' => 'raw',
'filter' => CHtml::activeTextField($model, 'searchcar','id'=>'Car_tb'),
);
array(
'name' => 'Count',
'header' => 'Count',
'value' => ???????
'type' => 'raw',

);

?>

My result :
---------------------------------
Owner | Car
---------------------------------
Peter Company | BMW
Johs Company | Volvo
Peter Company | BMW
---------------------------------

And what i want :
------------------------------------------------
Owner | Car | Count
------------------------------------------------
Peter Company | BMW | 2
Johs Company | Volvo | 1
-----------------------------------------------

Sorry for my bad english, but i hope its understandable :)
Thank you :)

help me

$
0
0
in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Connection.php at line 584
575576577578579580581582583584585586587588589590591592593

$token = 'Opening DB connection: ' . $this->dsn;
try {
Yii::info($token, __METHOD__);
Yii::beginProfile($token, __METHOD__);
$this->pdo = $this->createPdoInstance();
$this->initConnection();
Yii::endProfile($token, __METHOD__);
} catch (\PDOException $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), $e->errorInfo, (int) $e->getCode(), $e);
}
}

/**
* Closes the currently active DB connection.
* It does nothing if the connection is already closed.
*/
public function close()
{

2. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Connection.php at line 928 – yii\db\Connection::open()
3. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Connection.php at line 915 – yii\db\Connection::getMasterPdo()
4. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Command.php at line 219 – yii\db\Connection::getSlavePdo()
5. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Command.php at line 910 – yii\db\Command::prepare(true)
6. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Command.php at line 362 – yii\db\Command::queryInternal('fetchAll', null)
7. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\Query.php at line 213 – yii\db\Command::queryAll()
8. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\db\ActiveQuery.php at line 135 – yii\db\Query::all(null)
9. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\controllers\UsersController.php at line 15 – yii\db\ActiveQuery::all()
9101112131415161718

use yii\web\Controller;
use app\models\Users;
class UsersController extends Controller
{
public function actionIndex()
{
$users = Users::find()->all();
print_r($users);
}
}

10. app\controllers\UsersController::actionIndex()
11. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\base\InlineAction.php at line 57 – call_user_func_array([app\controllers\UsersController, 'actionIndex'], [])
12. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\base\Controller.php at line 156 – yii\base\InlineAction::runWithParams(['r' => 'users/index'])
13. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\base\Module.php at line 523 – yii\base\Controller::runAction('index', ['r' => 'users/index'])
14. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\web\Application.php at line 102 – yii\base\Module::runAction('users/index', ['r' => 'users/index'])
15. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\vendor\yiisoft\yii2\base\Application.php at line 380 – yii\web\Application::handleRequest(yii\web\Request)
16. in C:\xampp\htdocs\project\yii-basic-app-2.0.12\basic\web\index.php at line 12 – yii\base\Application::run()
6789101112


require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/../config/web.php');

(new yii\web\Application($config))->run();

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.

Open Real Estate Cms Based On Yii Framework

$
0
0
We are glad to represent you a free Open Real Estate CMS for websites of realtors and real estate agencies. It is ready to use. Just click monoray.net/products/6-open-real-estate
On this page you can find links to download the product and to try its DEMO.
In case you find bugs or issues, contact us.
We will be glad to know your opinion about the product, and whether you wish to add to it some new functions or not (in case the product has all the functions which you expect).

Thank you in advance.

Yii user setstate / getstate

$
0
0
I am using Yii framework and I want to use user setstate, getstate methods but found out some problems, please can you help me to solve them? here is my codes:

UserIdentity.php

protected function afterLogin()
{
    Yii::app()->user->setState('username', $record->username);
    Yii::app()->user->setState('privilages', $record->privilages);
}


man layout
array('label'=>Yii::app()->user->getState('username'), 'url'=>array('/user/index'), 'visible'=>!Yii::app()->user->isGuest),


when user loges in it doesn't show his username, it just show whitespaces. so can you tell me what is wrong with it?

Obsługa kilku kontrolerów na stronie

$
0
0
Hi grupowicze!!!

Proszę o pomoc. Szukam rozwiązania od dłuższego czasu.

Wstawiłem w szablonie strony 'protected/views/layouts/main.php' formularz pod warunkiem braku zalogowania.

<?php if(Yii::app()->user->isGuest) : ?>
	<?php $modelForm = new UserLoginRegistryForm; ?>
	<?php $modelForm->scenario = 'login'; ?>
	<?php $this->renderPartial('/user/_login', array('model' => $modelForm)); ?>
<?php endif; ?>


Problem polega na tym, że w wersji rejestracji formularz zawiera captche obsługiwaną ajax'owo. Submit jest podpięty do obsługującego formularz kontrolera ale jak podpiąć captche do tego kontrolera?

Chaptcha jest wywołana standardowym:

<?php if(CCaptcha::checkRequirements()): ?>
	<div class="row">
		<?php echo $form->labelEx($model, 'verifyCode'); ?>
		<div><?php $this->widget('CCaptcha'); ?></div>
		<div><?php echo $form->textField($model, 'verifyCode'); ?></div>
		<div class="hint">Please enter the letters as they are shown in the image above.<br/>Letters are not case-sensitive.</div>
		<?php echo $form->error($model, 'verifyCode'); ?>
	</div>
<?php endif; ?>


Dziękuję za pomoc.

Proyecto de Yii no funciona, ayuda!

$
0
0
Primero me presento, soy nuevo en la comunidad y agradezco por cualquiera quien me pueda ayudar!
Desarrolle una aplicación en yii 1.1.14 y la ando montando en producción, pero cuando intento ejecutarla, la página se queda en blanco!
Entonces cree un nuevo proyecto de yii desde cero en ese ambiente y cuando intento ejecutar la primera aplicación de ejemplo que genera me sale la página de la siguiente forma (ver archivo captura1.png)
: captura1.png

Revisando, logre percatarme que cuando comento la línea donde ejecuta el metodo widget ($this->widget) la pagina se renderiza correctamente, excepto los widgtes.

El ambiente de producción corre php 5.6.31 sobre apache 2.4 64 bits

Alguna idea de que podría ser?

Question: CGridView - How to override particular row's css ?

$
0
0
Hello everyone. I'm new to programming and very much interested in Yii.

I want to override particular columns back ground color should they meet particular requisitions. For example (this is not the actual case):
  • If the $data contains "porn" in one or more of its attributes, then change the respective row's back ground color to red.
  • If the $data contains "kids" in one or more of its attributes, then change the respective row's back ground color to green.
  • If the $data contains "action" in one or more of its attributes, then change the respective row's back ground color to blue.

Could any one please direct me on how to accomplish this simple task? A brief example would be very much appreciated.

Thank you very much in advance. And yes, i want to learn Yii more.

Por que escolhi o Yii Framework


Is it possible to move fliter box in Cgridview?

$
0
0
Hi,

Is it possible to Move fliter Box in Above table , Attached image for reference. Please give me solution for my problem or else please tell me possible or not

include(CJavaScriptExpression.php): failed to open stream: No such file or directory

$
0
0
Hi,

Am using Yii 1.1.8 Version Got error like,

include(CJavaScriptExpression.php): failed to open stream: No such file or directory

When add Below Code
<?php
echo CHtml::ajaxButton('ButtonName',Yii::app()->createUrl('/admin/m3sections/search'),
array(
'type'=>'POST',
'data'=> 'js:$("#fliter-form").serialize()',
'success'=>'js:function(data){ alert("teetee"); }' ,
'error'=>'js:function(data){ alert("comment NOT Submitted");}',
),array('class'=>'someCssClass',));
?>

Error al instalar adminlte

$
0
0
Buenos dias,

quiero instalar el AdminLTE pero al ingresar este siguiente codigo me sale el sifuiente error:

'view' => [
'theme' => [
'pathMap' => [
'@app/views' => '@vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app'
],
],
],

Agradeceria su gran ayuda

  • : Captura.PNG

Image Validation Clientoptions not working?

$
0
0
Hi,

I need Image Validation without Page refresh Input type text & select box it's working fine, But image Validation Working after only form submit only.

My Coding ,

Enable validateOnSubmit true.
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'enquiry-form',
'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
'htmlOptions' => array('enctype' => 'multipart/form-data',
'class'=>'contact_form'
),
)); ?>

Once Image upload wrong format need to show the validation error without page refresh how to show like?

Please Anyone tell me Is it possible or not AsAp.Because Am trying to fix this issue more than 4 hours.

Exportar Relatórios

$
0
0
Utilizando a mesma interface do _search criei alguns relatórios, onde o usuário escolhe alguns parâmetros e clicando em Gerar, o relatório é visualizado abaixo, na própria página. Até aí tudo perfeito. O problema é que gostaria também que cada relatório desse, mostrado abaixo, também mostrasse um botão para exportar pra Excel.
No controller criei o actionRelatorios que roda perfeito
public function actionRelatorios() {
    	$model = new rel_segunda('search');
    	$model->unsetAttributes();
    	if (isset($_GET['rel_segunda'])) {
        	$model->attributes = $_GET['rel_segunda'];
    	}
    	$this->pageTitle = Yii::app()->name . ' - Relatórios';  	
    	$this->render('relatorios', array('model' => $model));
}


Então tentei criar depois um actionresumoExcel para tentar exportar o relatório que está ativo, mais nada consigo.
public function actionresumoExcel() {
    	$model = new rel_segunda();
    	$model->unsetAttributes();
    	if (isset($_GET['rel_segunda']))
        	$model->attributes = $_GET['rel_segunda'];
  	
    	Yii::app()->request->sendFile('Resumo.xls', $this->renderPartial('relatorios/resumo', array(
                	'model' => $model
                    	), true)
    	);
	}

Ele não consegue visualizar as variáveis do model, e não retorna nada. Alguém pode me ajudar por favor neste probleminha??
Viewing all 18717 articles
Browse latest View live


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