0

i got problem when i tried to post submitbutton value.

<?= Html::submitButton('Save', ['value' => 'save','class' => 'btn green','name' => 'submit']) ?>

When i tried with that code, my value posted but i should click the button twice.

<?= Html::submitButton('Save', ['value' => 'save','class' => 'btn green','name' => 'button1']) ?>

But when i changed name button, the value not post. Any idea to solve this problem?

This my form :

<?php $form = ActiveForm::begin(); ?>

<?= Html::activeDropDownList($storev, 'id_store_v',$itemsv,
    [
        'prompt'=>'--Select Dealer--',
        'class'=>'form-control input-sm select2-multiple',
        //'onchange'=>'$("#namev").val($("#id_store_v option:selected").text());',
        'onchange'=>'$("input#idv").val($(this).val()),
                    $.post("index.php?r=sync/listsv&id='.'"+$(this).val(), function( data ) {
                        $("select#storev-address").html(data);
                    });'
    ])
?>

<?= $form->field($storev, 'id_store_v')->hiddenInput(['maxlength' => true, 'id'=>'idv'])->label(false) ?>

<?= $form->field($storev, 'address')->dropDownList(
    ArrayHelper::map(Storev::find()->all(),'id_store_v','address'), 
    [
        'prompt'=>'',
        'class'=>'form-control input-sm select2-multiple',
        'disabled'=> true,
    ])
?>


<?= Html::activeDropDownList($storetd, 'id',$itemstd,
    [
        'prompt'=>'--Select Dealer--',
        'class'=>'form-control input-lg select2-multiple',
        'multiple'=>'multiple',
        //'onchange'=>'$("#namev").val($("#id_store_v option:selected").text());',
        'onchange'=>'$("input#idtd").val($(this).val())'
    ])
?>
<?= $form->field($storetd, 'id')->hiddenInput(['maxlength' => true, 'id'=>'idtd'])->label(false) ?>

<?= Html::submitButton('Save', ['value' => 'save','class' => 'btn green','name' => 'button1']) ?>
<?= Html::submitButton('Check', ['value' => 'check','class' => 'btn yellow','name' => 'button1']) ?>
Suhendri
  • 13
  • 6

2 Answers2

0

try using a simple

  <?= Html::submitButton('Save', ['class' => 'btn btn-green']) ?>

and if you need a value try

  <?= Html::submitButton('Save', ['class' => 'btn btn-green', 'value'=>'save' ]) ?>
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • If i try like that, how can i post my submitbutton value? @scaisEdge – Suhendri Aug 11 '17 at 06:55
  • I am not able to get the name can you please see my [question](https://stackoverflow.com/q/66963449/6854117) related to it? – Moeez Apr 06 '21 at 06:12
  • I am trying to get the name but unable to get it can you please check my [question](https://stackoverflow.com/q/66963449/6854117)? – Moeez Apr 06 '21 at 07:13
0

Try this one View:

<?= Html::submitButton('Save', ['name' => 'form', 'value' => 'one']) ?>

Controller

if(Yii::$app->request->post('form') == 'one'){

}
Vishva G
  • 399
  • 7
  • 25
  • I am trying to get the name but unable to get it can you please check my [question](https://stackoverflow.com/q/66963449/6854117)? – Moeez Apr 06 '21 at 07:13