Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:19
    bizley closed #18950
  • 07:18
    bizley commented #18953
  • 07:18
    bizley closed #18953
  • Oct 15 21:08
    Arhell review_requested #18953
  • Oct 15 21:08
    Arhell ready_for_review #18953
  • Oct 15 21:08
    Arhell synchronize #18953
  • Oct 15 20:53
    Arhell labeled #18953
  • Oct 15 20:53
    Arhell opened #18953
  • Oct 15 18:04
    WinterSilence opened #18952
  • Oct 14 23:44
    neoacevedo opened #215
  • Oct 14 17:34
    raphaelts3 commented #18949
  • Oct 14 15:23
    jmar1998 opened #18951
  • Oct 14 14:38
    Arhell labeled #18950
  • Oct 14 14:38
    Arhell assigned #18950
  • Oct 14 14:38
    Arhell opened #18950
  • Oct 14 14:23
    raphaelts3 opened #18949
  • Oct 14 09:08
    bizley closed #18948
  • Oct 14 09:08
    bizley commented #18948
  • Oct 14 09:04
    EtienneBruines opened #18948
  • Oct 13 22:58
    WinterSilence synchronize #477
Lachee
@Lachee
as a work around, I have just resulted in using getter functions
matrixbot
@matrixbot
shurik2k5 see in my code phpDocs block before class - it helps IDE to operate with 'virtual' attributes
Lachee
@Lachee
oh i see
Muhd Danish
@unsolvedru
image.png
Hi, I'm tryna use authclient, everything went good until after google account select
image.png
inside SiteController.php
oh wait is this the correct place to ask
anjandas0211
@anjandas0211
I want to integrate a yii2 extension in yii2(humhub). How I do it?
Lachee
@Lachee
I have the following REST function
public function actionView($id, $period = null, $type = null)
and my ID is a compound key, ABN and Invoice Number
so when I am making a request, I would normally do api/transaction/abn,invoice
however, the invoice number contains -
which seem to break the routing.
api/11111111138,0242 works
api/11111111138,024-2 doesn't
error
silencer903
@silencer903
Hello everyone. someone can help me for problem with dataprovider+gridview+pjax ?
silencer903
@silencer903
i find answer)
Bpragnya
@Bpragnya
Hi this is pragnya can any one help me
Bpragnya
@Bpragnya
Hi this is pragnya can any one help me with conditional validation in ajax/ gii form in which i kept a conditional validation on check box if it is checked other dependent field is mandatory
It is working perfectly in non ajax but not in ajax form. To check i
Wrote a piece of code to alert value if checked not working in ajax
Any one plz help me with this problem as soon as possible
matrixbot
@matrixbot
shurik2k5 Hello! Show you code.
Bpragnya
@Bpragnya
hello shurik2k5

In model.php

[ ['section_incharge_designation_id1','incharge_from_dt1'],
'required',
'message' => 'Cannot be null',
'when' => function($model) {

                    return ($model->field1==1);
                    },
                    'enableClientValidation' => false
                    , 'whenClient' => "function (attribute, value) {

                                                     if(document.getElementById('field1').checked)
                                                            {return true  ;}
                                                            else{return false  ;}

                                     }"

                            ],

In controller
public function actionCreate()
{
$request = Yii::$app->request;
$model = new EmsSectionMst();
$section_details_model=new EmsSectionInchargeDtl();

    if($request->isAjax){
        /*
         *   Process for ajax request
         */
        Yii::$app->response->format = Response::FORMAT_JSON;
        if($request->isGet){
            return [
                    'title'=> "Create new EmsSectionMst",
                    'content'=>$this->renderAjax('create', [
                            'model' => $model,'section_details_model'=>$section_details_model
                    ]),
                    'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                    Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])

            ];
        }else if($model->load($request->post()) && $model->validate())
        {

                    return [
                    'forceReload'=>'#crud-datatable-pjax',
                    'title'=> "Create new EmsSectionMst",
                    'content'=>'<span class="text-success">Create EmsSectionMst success</span>',
                    'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                    Html::a('Create More',['create'],['class'=>'btn btn-primary','role'=>'modal-remote'])

                    ]; 

        }else{
            return [
                    'title'=> "Create new EmsSectionMst",
                    'content'=>$this->renderAjax('create', [
                            'model' => $model,'section_details_model'=>$section_details_model
                    ]),
                    'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                    Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])

            ];
        }

    }else{
        /*
        *   Process for non-ajax request
        */
        if ($model->load($request->post()) && $model->validate()
                //&& $model->save()
                ) {

            return $this->redirect(['view', 'id' => $model->section_id]);
        } else {
            return $this->render('create', [
                'model' => $model,
                    'section_details_model'=>$section_details_model
            ]);
        }
    }

}
not working in ajax
matrixbot
@matrixbot
shurik2k5 paste code in markdown code block
Bpragnya
@Bpragnya
````
In model.php


[        ['section_incharge_designation_id1','incharge_from_dt1'],
                        'required',
                        'message' => 'Cannot be null',
                        'when' => function($model) {

                        return ($model->field1==1);
                        },
                        'enableClientValidation' => false
                        , 'whenClient' => "function (attribute, value) {
                                //alert(document.getElementById('field1').value);
                                                         if(document.getElementById('field1').checked)
                                                                {return true  ;}
                                                                else{return false  ;}

                                         }"

                                ],
In controller.php

 public function actionCreate()
    {
        $request = Yii::$app->request;
        $model = new EmsSectionMst();  
        $section_details_model=new EmsSectionInchargeDtl();

        if($request->isAjax){
            /*
             *   Process for ajax request
             */
            Yii::$app->response->format = Response::FORMAT_JSON;
            if($request->isGet){
                return [
                        'title'=> "Create new EmsSectionMst",
                        'content'=>$this->renderAjax('create', [
                                'model' => $model,'section_details_model'=>$section_details_model
                        ]),
                        'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                        Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])

                ];
            }else if($model->load($request->post()) && $model->validate())
            {
                        echo"<br>post<br>";
                        print_r($model->load($request->post()));
                        echo"<br>vali<br>";
                        print_r($model->validate());
                        echo"<br>deta<br>";
                        print_r($section_details_model->validate());
                        echo "<br>sdfsf<br>";
                        print_r($_POST);
                        /*         die();

                        return [
                        'forceReload'=>'#crud-datatable-pjax',
                        'title'=> "Create new EmsSectionMst",
                        'content'=>'<span class="text-success">Create EmsSectionMst success</span>',
                        'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                        Html::a('Create More',['create'],['class'=>'btn btn-primary','role'=>'modal-remote'])

                        ];  */
            }else{
                return [
                        'title'=> "Create new EmsSectionMst",
                        'content'=>$this->renderAjax('create', [
                                'model' => $model,'section_details_model'=>$section_details_model
                        ]),
                        'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                        Html::button('Save',['class'=>'btn btn-primary','type'=>"submit"])

                ];
            }

        }else{
            /*
            *   Process for non-ajax request
            */
            if ($model->load($request->post()) && $model->validate()
                    //&& $model->save()
                    ) {
                print_r($_POST);

                die();
                return $this->redirect(['view', 'id' => $model->section_id]);
            } else {
                return $this->render('create', [
                    'model' => $model,
                        'section_details_model'=>$section_details_model
                ]);
            }
        }

    }
Bpragnya
@Bpragnya
In view.php

<div class="ems-section-mst-forma">

    <?php $form = ActiveForm::begin(['id' => 'sectionmst-form',
                    //'enableAjaxValidation' => true,
                    /* 'validateOnSubmit'=>true,
                    'enableAjaxValidation' => true,
                    'enableClientValidation' => true, */
                    //'id' => 'ajax'
                    ]); ?>
 $i=1;
    foreach ($site_dtls as $dtls)
    { ?>
   <!--<input type="checkbox" id= $dtls->site_id?> value= $dtls->site_id?>><b>Active in $dtls->site_code?></b><br>-->
   <?= $form->field($section_details_model, 'field'.$i)->checkbox(['id'=>'field'.$i,
                   //'id'=>$dtls->site_id,
                   'value'=>$dtls->site_id,'label'=>'Active in '.$dtls->site_code,
                   'onchange'=>"show_other_fields(this,'$i');"
   ]);?>
<div class="row">
      <div class="col-sm-12 col-md-12 col-lg-12 hidden-item" id="<?= $i?>section_incharge_designation_id_div">
   <?= $form->field($section_details_model, 'section_incharge_designation_id'.$i)->widget(Select2::className(),[
                   'data'=>Fields_detail::get_all_designations(),

                   'options'=>['autofocus' => true,'prompt'=>'Select Designation','id'=>$i.'section_incharge_designation_id'],
   ])->label('Section Incharge Designation in '.$dtls->site_code);?>

   </div>
  </div>
<?php

   $i++;
    }?>
matrixbot
@matrixbot
shurik2k5 paste model code again
Bpragnya
@Bpragnya
In model.php (conditional validation)

    public function rules()
    {
        return [
                [['official_email_id1','official_email_id2'],'email','message'=>'Not a valid Email Address'],
    [        ['section_incharge_designation_id1','incharge_from_dt1'],
                        'required',
                        'message' => 'Cannot be null',
                        'when' => function($model) {

                        return ($model->field1==1);
                        },
                        'enableClientValidation' => false
                        , 'whenClient' => "function (attribute, value) {
                                //alert(document.getElementById('field1').value);
                                                         if(document.getElementById('field1').checked)
                                                                {return true  ;}
                                                                else{return false  ;}

                                         }"

                                ],
];
}
Bpragnya
@Bpragnya
````
``
    [        ['section_incharge_designation_id1','incharge_from_dt1'],
                        'required',
                        'message' => 'Cannot be null',
                        'when' => function($model) {

                        return ($model->field1==1);
                        },
                        'enableClientValidation' => true
                        , 'whenClient' => "function (attribute, value) {
                                alert('hgello');
                                                         if(document.getElementById('field1').checked)
                                                                {return true  ;}
                                                                else{return false  ;}

                                         }"

                                ],
matrixbot
@matrixbot
shurik2k5 paste you code to gist https://gist.github.com/
Bpragnya
@Bpragnya
again?
Bpragnya
@Bpragnya
Yeah done
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