I have created active form in my yii2 application with following code
$form = ActiveForm::begin([
'id' => 'deposit-form',
'enableClientValidation' => true,
'fieldConfig' => [
'template' => '{input}{error}',
'options' => [
'tag' => false
]
],
'action' => 'create',
'options' => [
'class' => 'form-horizontal',
'method' => 'post',
]
])
however my form is not displaying any mthod i.e, get or post. output of my form is
<form role="form" class="form-horizontal">
I wan't it as <form role="form" class="form-horizontal" method="POST">
How to achieve following result I also tried this code
$form = ActiveForm::begin([
'id' => 'deposit-form',
'enableClientValidation' => true,
'fieldConfig' => [
'template' => '{input}{error}',
'options' => [
'tag' => false
]
],
'action' => 'create',
'method' => 'post',
'options' => [
'class' => 'form-horizontal',
]
])
In the official documentation:
$method public property:
The form submission method. This should be either 'post' or 'get'. Defaults to 'post'.
$form = ActiveForm::begin([
'method' => 'get',
'action' => ['controller/action'],
]);
Use Following, you can add other properties also. Your code is also correct, but I think you are not ending your form.
<?php $form = \yii\bootstrap\ActiveForm::begin([
'id' => 'deposit-form',
'enableClientValidation' => true,
'method'=>'post'
]);
\yii\bootstrap\ActiveForm::end();
?>