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
Lachee
@Lachee
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
when the ActiveForm is submitted, it triggers the PJax which reloads the GridView
Lachee
@Lachee
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
Rami Serapian
@rami11
Hi everyone! How do I upgrade to bootstrap 4 in yii? Is there any helpful document that explains how to do so?
Lachee
@Lachee

What is the best practice for using Access Tokens in apis?

        $identity = self::find()->where(['access_token' => $token])->select('id')->one();
        if ($identity == null) return null;

        //As per the recommendations, https://www.yiiframework.com/doc/api/2.0/yii-web-identityinterface#findIdentityByAccessToken()-detail
        // null should be re turned here.
        if (!Yii::$app->authManager->checkAccess($identity->id, Permissions::IdentifyWithAccessToken))
            return null;    

        return $identity;

this doesn't seem all that secure having it in plain text.

Alexander Makarov
@samdark
jhd235
@jhd235
https://www.yiiframework.com/extension/yiisoft/yii2-debug/doc/guide
when the "Development Tools" chapter is going to be created, please?
Kai Mindermann, M.Sc.
@kmindi
Hi, I have two models that have a many to many relation. In the create action of the controller for model A I want to create an entry in the junction table to "link" model B. Yet I get the following error: UnknownPropertyException
This is how I call the linking after the $model was saved $model is an Organisation, organisationUsers is the junctiontable/model for linking organisations to users: $model->link('organisationUsers', Yii::$app->user->identity, ['status' => 10, 'role' => 10]);.
This is the next called method in the stack trace: in /app/vendor/yiisoft/yii2/db/BaseActiveRecord.php at line 1350– yii\db\BaseActiveRecord::bindModels(['organisation_id' => 'id'], common\models\User, common\models\Organisation).
in /app/vendor/yiisoft/yii2/db/BaseActiveRecord.php at line 1574– yii\db\BaseActiveRecord::__get('organisation_id')
Kai Mindermann, M.Sc.
@kmindi
Fixed it, I was using the junction table relation instead of the relation to users
matrixbot
@matrixbot
qncm Hey. I'm populating dropdownlist for a nullable field. What should be the key here: [ ??? => 'nothing', ...]?
Nouras Hamwi
@NourasHamwi
Any idea why would isGuest and user identity only works in SiteController and not other controllers?
Nouras Hamwi
@NourasHamwi
isGuest works fine in frontend and backend but the problem is happenening when you add a third application I followed Yii2 documentation to create an additional application which works find just user identity is not working outside of sitecontroller.
Lachee
@Lachee
How do I override the base MOdel class using DI?

I have tried

'container' => [
        'definitions' => [
            yii\base\Model::class => app\models\Model::class,

but that doesn't do anything. The models dont have any of the app\models\Model::class and are not instances of it

 $model = TestModel::findOne(['id' => 3]);
 $success = $model instanceof \app\models\Model;
  if (!$success) Yii::$app->session->addFlash('danger', 'failed to override');
this always fails
Alexander Makarov
@samdark
Christopher Stebe
@Quexer69

Hey guys, I have a question regarding the yiisoft/yii2-queue and the monitor extension from Roman Zhuravlev. I need to implement a worker affinity for jobs.

I start worker using supervisor in docker container (1 or many):

[group:worker]
programs=yii-queue-worker
priority=40

[program:yii-queue-worker]
command=yii queue/listen --verbose=1 --php-binary=/usr/local/bin/php --isolate=1 --color=0 --interactive=0
process_name=%(program_name)s_%(process_num)02d
autostart=true
numprocs=5
autorestart=true
startsecs=14
startretries=20
user=application
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

So I have 5 isolated queue listeners up and running in each container / host.
Now a job A was pushed for the first time and gets executed by worker A on host A.
Then I remember (using a simple key value store in redis) that job A was processed by worker A on host A.
Works fine so far and I can access that information everywhere.

Now the next time job A comes I need to ensure that this job A will only gets executed on worker A on host A.
Until worker A on host A is busy that job A needs to wait.

I tried a lot to get that done but job A gets always executed by one of the next free available worker process.

I use own extended classes doing nothing atm then calling the parent class methods to be able to customize.
Here`s my config:

'queue' => [
            'class' => ProjectQueue::class,
            'commandClass' => ProjectCommand::class,
            'as log' => [
                'class' => ProjectLogBehavior::class,
                'autoFlush' => true,
            ],
            'as jobMonitor' => [
                'class' => ProjectJobMonitor::class,
            ],
            'as workerMonitor' => [
                'class' => ProjectWorkerMonitor::class,
            ],
            'mutex' => [
                'class' => MysqlMutex::class,
                'db' => 'db',
                'autoRelease' => false,
            ],
            'mutexTimeout' => 10,
            'db' => 'db',
            'channel' => 'master-queue', 
            'deleteReleased' => true, 
            'ttr' => 200,
            'attempts' => 1,
        ],

Now my question. Is that possible at all? And where I need to slide in to get that done.

Thanks in advance !

Alexander Makarov
@samdark
Alexander Makarov
@samdark

🎁 Yii news 2020, issue 8: https://opencollective.com/yiisoft/updates/yii-news-2020-issue-8

🎄 Happy New Year!

Alexander Makarov
@samdark
Alexander Makarov
@samdark
kiti_Nomad
@Kiti-Nomad
php