PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 27, 2022

[FIXED] how to show 2 form from same table in search

 February 27, 2022     yii, yii2, yii2-advanced-app, yii2-basic-app     No comments   

Issue

I want to ask, how to show 2 forms from the same table with a related table in yii2,

example

<?php
    $label1 = app\models\AppFieldConfigSearch::getLabelName(Location::tableName(), "Location");
    ?>
    <?= $form->field($model, 'id_location')->label($label1) ?>


    <?php
        $label1 = app\models\AppFieldConfigSearch::getLabelName(LocationUnit::tableName(), "label1");
    ?>
    <?= $form->field($model, 'label1')->label($label1) ?>

    <?php $dataListAssetMaster2 = ArrayHelper::map(Owner::find()->asArray()->all(), 'id_owner', 'name');
    echo $form->field($model, 'id_owner')->widget(Select2::classname(), [
        'data' => $dataListAssetMaster2,
        'pluginOptions' => [
            'allowClear' => true
        ],
        'options' => [
            'prompt' => 'Pilih Nama']
    ])->label("Name");
    ?>
    <?php $dataListAssetMaster4 = ArrayHelper::map(Location::find()->asArray()->all(), 'id_location', 'address');
    echo $form->field($model, 'id_location')->widget(Select2::classname(), [
        'data' => $dataListAssetMaster4,
        'pluginOptions' => [
            'allowClear' => true
        ],
        'options' => [
            'prompt' => 'Status Pembebasan']
    ])->label("location address");

// my search model

public function rules()
{
    return [
        [['id_location_unit', 'id_location', 'id_owner','id_mst_status1'], 'integer'],
        [['label1', 'label2', 'label3', 'keterangan1', 'keterangan2', 'keterangan3','address'], 'safe'],
    ];
}

I want to display the same 2 tables on 1 search form, but I have a problem when I use the code, one of the forms does not appear


Solution

You can combine 2 of your model/form into 1 search model. Let your search model decide on the search logic.



Answered By - Godzilla
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing