Example #1
0
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data', 'id' => 'dynamic-form']]);
?>

    <?php 
echo $form->field($modelClassified, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($modelClassified, 'description')->textarea(['rows' => 6]);
?>

    <!-- Main Category -->
    <?php 
$listDataMainCategory = \yii\helpers\ArrayHelper::map(common\models\MainCategory::find()->all(), 'id', 'main_category');
?>
    <?php 
echo $form->field($modelClassified, 'main_category_id')->dropDownList($listDataMainCategory, ['prompt' => '-- Select Main Category --', 'onChange' => '
                        $.get("' . yii\helpers\Url::toRoute(['dependent/getcategory']) . '", { id: $(this).val() })
                                .done(function(data){
                                    $("#' . Html::getInputId($modelClassified, 'category_id') . '").html( data );
                                });']);
?>

    <!-- Category -->
    <?php 
$listDataCategory = \yii\helpers\ArrayHelper::map(common\models\Category::find()->all(), 'id', 'category');
?>
    <?php 
if (isset($modelClassified->category_id)) {
Example #2
0
                <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data', 'id' => 'dynamic-form']]);
?>

                <?php 
echo $form->field($modelClassified, 'title')->textInput(['maxlength' => true]);
?>

                <?php 
echo $form->field($modelClassified, 'description')->textarea(['rows' => 6]);
?>

                <!-- Main Category -->
                <?php 
$listDataMainCategory = \yii\helpers\ArrayHelper::map(common\models\MainCategory::find()->where(['is_status' => 1])->all(), 'id', 'main_category');
?>
                <?php 
echo $form->field($modelClassified, 'main_category_id')->dropDownList($listDataMainCategory, ['prompt' => '-- Select Main Category --', 'onChange' => '
                        $.get("' . yii\helpers\Url::toRoute(['dependent/getcategory']) . '", { id: $(this).val() })
                                .done(function(data){
                                    $("#' . Html::getInputId($modelClassified, 'category_id') . '").html( data );
                                });']);
?>

                <!-- Category -->
                <?php 
$listDataCategory = \yii\helpers\ArrayHelper::map(common\models\Category::find()->where(['is_status' => 1])->all(), 'id', 'category');
?>
                <?php 
if (isset($modelClassified->category_id)) {