Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:10
    bizley synchronize #18800
  • Aug 01 23:39
    Arhell edited #18801
  • Aug 01 23:39
    Arhell labeled #18801
  • Aug 01 23:39
    Arhell assigned #18801
  • Aug 01 23:39
    Arhell opened #18801
  • Aug 01 17:56
    bizley review_requested #18800
  • Aug 01 17:56
    bizley opened #18800
  • Aug 01 17:56
    bizley labeled #18800
  • Aug 01 17:56
    bizley assigned #18800
  • Aug 01 17:56
    bizley milestoned #18800
  • Aug 01 15:27
    WinterSilence synchronize #18799
  • Aug 01 14:26
    WinterSilence synchronize #18799
  • Aug 01 14:24
    WinterSilence synchronize #18799
  • Aug 01 14:23
    WinterSilence opened #18799
  • Aug 01 12:22
    WinterSilence edited #18796
  • Aug 01 11:04
    samdark labeled #18798
  • Aug 01 11:04
    samdark labeled #18798
  • Aug 01 10:40
    WinterSilence opened #18798
  • Aug 01 07:05
    bizley closed #18792
  • Aug 01 07:05
    bizley commented #18792
matrixbot
@matrixbot
shurik2k5 Im model
'enableClientValidation' => false
Bpragnya
@Bpragnya
if i made it false how would validation work !!
although i made if false and tried too
but it didnt works
image.png
image.png
matrixbot
@matrixbot
shurik2k5 php <?php $form = ActiveForm::begin(['id' => 'sectionmst-form', 'enableAjaxValidation' => true, ]); ?>
uncomment enableAjaxValidation in view
Bpragnya
@Bpragnya
image.png
didnot work again by checking flag and submitting it it again refresh whole page and validatinig first field not others where i kept contional valition
image.png
image.png
Karugi Gitau
@gkarugi

Hey guys..

I am having a problem with rest routes - am getting 404.

I have a model - Product

<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "products".
 *
 * @property int $id
 * @property string $name
 * @property int $supplier_id
 */
class Product extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'products';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['supplier_id'], 'integer'],
            [['name'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'supplier_id' => 'Supplier ID',
        ];
    }
}

Controller - ProductController

<?php

namespace app\Controllers;

use app\models\Product;
use yii\data\ActiveDataProvider;
use yii\rest\ActiveController;

class ProductController extends ActiveController
{
    public $modelClass = 'app\models\Product';
    public $serializer = [
        'class' => 'yii\rest\Serializer',
        'collectionEnvelope' => 'items',
    ];

    public function actionIndex()
    {
        var_dump('here');
    }
}

and routes in url manager

...
 'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => true,
            'rules' => [
                ['class' => 'yii\rest\UrlRule', 'controller' => 'product'],
            ],
        ],
...

What am I missing?

Alex
@alexssdd
@gkarugi
    public function actions()
    {
        $actions = parent::actions();
        unset($actions['index']);

        return $actions;
    }
paratout
@paratout
Hi
Lachee
@Lachee
The web Request gets confused when trying to resolve ID's with letters in them
/transactions/10 works fine
/transactions/10,5 works fine
but when you do
/transactions/10,5f
it gets confused and thinks that the action is 10,5f instead of view like the others have
resolve() in the web/Request is the cause
actually I should say its the URL manager
Lachee
@Lachee
nevermind, I resolved the issue myself by duplicating the rest\UrlRule and changing its allowed-tokens to [a-zA-Z0-9][a-zA-Z0-9,-_]*
hmm, still cannot get
11111111138,024d7994-a26c-4c20-9894-13934840fc31 working using that, but I guess I can live without the dashes
Alexander Makarov
@samdark
liyuze
@liyuze

Server suddenly returns error code 500

It is found that the IO speed of the hard disk of the php-fpm process is 130Mb/s , and the corresponding file is /runtime/logs/app.log

Q A
Yii version 2.0.22
PHP version 7.1
Operating system linux

main.php

'log' => [
    'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['info','error', 'warning'],
            'logVars' => ['_GET','_POST'],//记录全局变量的参数,$_GET,$_SERVER...,默认会增加一条info记录
            'logFile' => '@app/runtime/logs/-app.log',
            'maxFileSize' => 1024 * 2000,       // 2G
            'maxLogFiles' => 1,
        ]
    ],
],

When I read the source code in vendor/yiisoft/yii2/log/FileTarget.php, I found that I should set rotateByCopy = false.

file:vendor/yiisoft/yii2/log/FileTarget.php

/**
* @var bool Whether to rotate log files by copy and truncate in contrast to rotation by
* renaming files. Defaults to `true` to be more compatible with log tailers and is windows
* systems which do not play well with rename on open files. Rotation by renaming however is 
* a bit faster.
*
* The problem with windows systems where the [rename()](https://secure.php.net/manual/en/function.rename.php)
* function does not work with files that are opened by some process is described in a
* [comment by Martin Pelletier](https://secure.php.net/manual/en/function.rename.php#102274) in
* the PHP documentation. By setting rotateByCopy to `true` you can work
* around this problem.
*/
public $rotateByCopy = true;

But I don't think this configuration will cause the server to stop serving.Then I found a bit of confusion.

file:vendor/yiisoft/yii2/log/FileTarget.php

    public function export()
    {
        $logPath = dirname($this->logFile);
        FileHelper::createDirectory($logPath, $this->dirMode, true);

        $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n";
        if (($fp = @fopen($this->logFile, 'a')) === false) {
            throw new InvalidConfigException("Unable to append to log file: {$this->logFile}");
        }
        @flock($fp, LOCK_EX);   ########### lock file
        if ($this->enableRotation) {
            clearstatcache();
        }
        if ($this->enableRotation && @filesize($this->logFile) > $this->maxFileSize * 1024) {
            @flock($fp, LOCK_UN);   ########### unlock file
            @fclose($fp);
            $this->rotateFiles();   ########### when rotateByCopy = true , copying file content to aother file is slow (2GB size). Causes multiple php-fpm processes copy files at the same time
            ########### Why unlock file before rotateFiles() @see:https://github.com/yiisoft/yii2/pull/3563#issuecomment-425630598
            ########### Maybe we need a separate lock file for rotateFiles().
            // ...
        } else {
            // ...
        }
        // ...
    }

Is my idea right?

Alexander Makarov
@samdark
:information_source: Yii 1, Yii 2.0.31 and Yii 3 progress: https://opencollective.com/yiisoft/updates/yii-1-yii-2-0-31-and-yii-3-progress
Lachee
@Lachee
Im having some issue with Pjax
it seems to reregister a widgets Javascript
which calls the widget to be executed twice
The widget is called like:
public function init() {
   parent::init();
   $this->view->registerJs(/* JS Code */, View::POS_READY, 'modalform');
}
and the view looks like:
    <?php \yii\widgets\Pjax::begin([ 'id' => 'pgrid' ]); ?>

                        <?= ModalForm::widget([ 
                                          //THIS IS THE WIDGET WITH DUPLICATED JS
                        ]); ?>

                        <?php $form = ActiveForm::begin(['method' => 'POST', 'options' => ['data-pjax' => true, 'class' => 'bmd-form-group bmd-form-group-sm']]); ?>
                                    <!-- ['inputOptions' => ['autofocus' => 'autofocus'] ] -->
                                    <?= $form->field($searchModel, 'query')->textInput( ['id' => 'inputField', 'placeholder' => 'Search records'])->label(false); ?>
                                    <?= Html::submitButton('<i class="material-icons">search</i>', [ 'class' => 'btn btn-rose btn-round btn-just-icon' ]); ?>
                            <?php ActiveForm::end(); ?>
                            <script>
                                $('#inputField').on('change', function(ev) {
                                    $(this).parents('form').submit();
                                    ev.preventDefault();
                                });
                            </script>


                    <?= GridView::widget([]); ?>
So basically, there is a smart button that does a bunch of Javascript called ModalForm, a ActiveForm for searching and a GridView
Lachee
@Lachee
when the ActiveForm is submitted, it triggers the PJax which reloads the GridView
problem is that the Pjax for some reason is deciding that the ModalForm widget needs its JS registered again
a really dirty temporary fix is simply to skip registering the JS if its Pjax request, but I feel like this isn't the most ideal solution to have in the widget controller.
if (! Yii::$app->request->isPjax)
    $this->view->registerJs(/* stuff */);
Alexander Makarov
@samdark
Alexander Makarov
@samdark
Lachee
@Lachee
Too few arguments to function app\controllers\ClaimController::actionUpdate(), 0 passed and exactly 1 expected
http://iqv2.com:81/claim/update?id=3
wtf
img
why is this not working?
works on literally every other script I have
yii\base\Controller versus yii\web\Controller
thanks
Vũ Mạnh Cường
@github-cuongvm
Hi all.
i use buttflattery\formwizard\FormWizard for my Project
But i can't get stepID on each step
I need enable/disable or add new button in wizard on each step.
Can you help me?
Vũ Mạnh Cường
@github-cuongvm
:(
Alexander Makarov
@samdark