yii2

DropDownList yii 2.0 example

孤街浪徒 提交于 2020-01-23 06:08:57
问题 I am using yii 2.0 Framework. How i can make options from my database. I found this, but it's yii 1.1: <?php echo CHtml::dropDownList('listname', $select, array('M' => 'Male', 'F' => 'Female')); I want to pass it to form: <?php $form->dropDownList() ?> How i can fill my dropdownlist from my database table? 回答1: Use yii\helpers\Html it contains Html::dropDownList() . echo Html::dropDownList('listname', $select, ['M'=>'Male', 'F'=>'Female']); Check Yii Framework 2.0 API Controller public

DropDownList yii 2.0 example

≡放荡痞女 提交于 2020-01-23 06:06:58
问题 I am using yii 2.0 Framework. How i can make options from my database. I found this, but it's yii 1.1: <?php echo CHtml::dropDownList('listname', $select, array('M' => 'Male', 'F' => 'Female')); I want to pass it to form: <?php $form->dropDownList() ?> How i can fill my dropdownlist from my database table? 回答1: Use yii\helpers\Html it contains Html::dropDownList() . echo Html::dropDownList('listname', $select, ['M'=>'Male', 'F'=>'Female']); Check Yii Framework 2.0 API Controller public

Reportico : yii2 How to embed Links?

浪子不回头ぞ 提交于 2020-01-17 07:37:58
问题 I have created a Reportico Project named "atom" and a Report called "Receipts" and then I created action=receipts in ReportController. This is the tutorial I followed: Controller code : public function actionReceipts() { return $this->render('receipts'); } I created receipts.php <?php use yii\helpers\Html; use yii\helpers\Url; $this->title = Yii::t('app', 'Reports'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="report-index"> <div class="container"> <div class="row"> <div

How to use Url::remember in yii2

故事扮演 提交于 2020-01-17 05:41:29
问题 I want to create a link on my error page to take user back to the previous link. Suppose the current URL is http://example.com/site/product, and a user try to view http://example.com/site/product?id=100 and a product with id =100 does not exit, the system should throw 404 error to the error page, now if i want to create a link to take the user back to http://example.com/site/product the previous URl how do I make this work. i can make this work by hardcoding this in my error views file, but i

Config mailer parameters from model - Yii2

妖精的绣舞 提交于 2020-01-17 05:36:08
问题 im using Yii2 and i want to config mailer parameters geting the data from db. Example: 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'enableSwiftMailerLogging' =>true, 'useFileTransport' => false, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => $model->getSmtpHost(), 'username' => $model->getSmtpUser(), 'password' => $model->getSmtpPass(), 'port' => $model->getSmtpPort(), 'encryption' => $model->getSmtpEncryption(), ], ] but from web.php can't call methods from models, i

How to add google-chart correctly in Yii2?

拜拜、爱过 提交于 2020-01-17 04:30:05
问题 I have added the extension (a wraper for google chart) "scotthuangzl/yii2-google-chart": "dev-master" to the require section of my composer.json file. However when I call that extension on views\site\myPage.php I have this error: Class 'scotthuangzl\googlechart\GoogleChart' not found. What I am doing wrong? Thanks. This is the code where I call the google chart: <?php use scotthuangzl\googlechart\GoogleChart; echo GoogleChart::widget(array('visualization' => 'BarChart', 'data' => array( array

AJAX call unable to send a request Yii2

妖精的绣舞 提交于 2020-01-16 09:43:10
问题 I have an AJAX call in my view. The code of it looks like this: <?php $this->registerJs(" $(document).on('click','.btn-block',function(){ var id = $(this).parents('.user-tr').attr('id'); $.ajax({ url: '" . Yii::$app->request->baseUrl . "admin/block-users', type: 'POST', data: {id : id,_csrf : " . Yii::$app->request->getCsrfToken() . "}, success: function (data) { console.log(data); }, }); })"); ?> I need to send a request to my actionBlockUsers function of AdminController , which looks like

Convert PDF to HTML in PHP similar to DocuSign

南楼画角 提交于 2020-01-16 09:01:49
问题 we are developing a website that needs to convert PDF files into HTML because some of the PDF has a form (not necessarily fillable PDF, these PDFs are printed to be filled up). So we want it to be filled up through our website instead of printing the files and filled up by pen. We are going paperless. DocuSign provides these wherein you can upload PDF, then you can customized it to have textboxes, checkbox. So we're kinda using DocuSign as a reference but still haven't figured out how they

Yii2. Pjax and Session

馋奶兔 提交于 2020-01-16 07:18:49
问题 For testing reasons, I am trying to use Pjax in a widget. In the view: $testArgs = [ 'param' => 'test' ]; Yii::$app->session->set('testArgs', $testArgs); echo Test::widget($testArgs); Then in the widget: class Test extends Widget { public $param; .. public function init() { .. } public function run() { Pjax::begin(); echo "<a href='test/add'>[ + ]</a> | <a href='test/remove'>[ - ]</a>"; Pjax::end(); } } Then in TestController: public function actionAdd() { $testArgs = Yii::$app->session->get(

Yii2: How do you use named parameters in console commands?

青春壹個敷衍的年華 提交于 2020-01-16 06:14:31
问题 How can I write the console command yii controller/action --param1=something --param2=anything and retrieve those named parameters in the action? 回答1: I found out that the documentation does say how to, but instead of calling it "named parameters" as I expected it to, it is called options: http://www.yiiframework.com/doc-2.0/guide-tutorial-console.html#create-command The docs is not quite complete though. So here is an example: You add the parameters as properties to the controller: class