ActiveForm is a widget that builds an interactive HTML form for one or multiple data models.
Questions tagged [active-form]
184 questions
31
votes
5 answers
How to change label text of the ActiveField?
I have created new Yii2 basic project and want to dig in.
There is a Username field on login page:
I want to change label 'Username' to a custom one, e.g. 'My superb label'.
I have read the…

Vadym
- 1,067
- 1
- 13
- 24
29
votes
2 answers
Yii2 - ActiveForm ajax submit
How can i use ActiveForm with these requirements?
Submit form with ajax.
Before submitting with ajax: Check if error exits.
After submitting: Display error of field under field's input if the server responses unsuccess saving result.

Văn Thái Nguyễn
- 291
- 1
- 3
- 4
18
votes
4 answers
yii2 ActiveForm numeric textfield
I've created an ActiveForm using yii2 like this:
=$form->field($item, 'finalPrice', [
'options' => [
'tag' => 'div',
…

Ofershap
- 687
- 2
- 7
- 22
13
votes
3 answers
Yii2 activeform ajax submit and validation
Currently to achieve ajax submit and validation at the same time. I'm using custom function like:
$('.edit_form').submit(function (e) {
e.preventDefault();
var form = $(this);
var formData = $(this).serialize();
…

heron
- 3,611
- 25
- 80
- 148
12
votes
4 answers
How to preselect/check a default radio button in yii2 RadioList()?
I want the radio button preselected in my form.
= $form->field($model, 'config')->radioList(['1'=>'Automatic Entry',2=>'Manual Entry'])
->label('Barcode/Book No Generation'); ?>

Insane Skull
- 9,220
- 9
- 44
- 63
10
votes
2 answers
Redirect from one view to another view - Yii2
This is my form in the view page of my website.
= $form->field($model, 'taskID')->textInput(['readonly' => true, 'value' => Yii::$app->getRequest()->getQueryParam('id')]) ?>

Choxx
- 945
- 1
- 24
- 46
9
votes
3 answers
Yii2: Either one field is required Validation
I have to implement the validation as mentioned in the title that either one of the two fields (email, phone) is required. I am doing this in my model:
[['email'],'either', ['other' => ['phone']]],
And this is the method:
public function…

Saani
- 791
- 7
- 28
- 68
9
votes
3 answers
yii2 active field template
It seems template for checkbox in sample yii2 project doesn't not apply correctly
= $form->field($model, 'rememberMe', [
'template' => "
{input}
\n
Herokiller
- 2,891
- 5
- 32
- 50
9
votes
4 answers
yii2: make checkbox to be checked
I am using Yii2 framework and I'd like to generate an html code like this
in a view which uses ActiveForm.
I've tried
echo $form->field($model, 'order')
…

Andrew
- 2,148
- 5
- 23
- 34
8
votes
1 answer
issue in sending form data to controller in yii2
I want to send form data from my view to the controller to insert the data in the database. I've created the model and the controller but when I'm sending the form to the controller with the action. It just refreshed the page the data is not passed…

TheDevWay
- 1,363
- 1
- 16
- 45
8
votes
4 answers
jQuery(...).activeform is not a function in Yii
I am developing a project with Yii.
I need to use jquery ui on many pages of site. So I add jquery core library and jquery ui library in the layout of site to have access to them on all the pages.
But it causes problem on the pages which have a form…

hd.
- 17,596
- 46
- 115
- 165
6
votes
3 answers
How to add id preix for field in activeForm?
i have two forms holds the same model attributes, since Yii2 generate the field id to be ModelName-fieldName so the field generated will be as follow:

git push origin master
- 171
- 3
- 12
6
votes
4 answers
Radio Button group in separate place in yii2
So, I want to have two radio button in separate place, I have been trying to search for the solution and everyone suggests to use radiolist which is not possible in my case.
If I put it like this (work_part_time button) : (below)
…

Robert Limanto
- 2,068
- 4
- 17
- 27
6
votes
2 answers
How to update widget with pjax in modal window in yii2
I have two ActiveForms in a modal window and after submitting first form, I need to update second one and stay in modal.
As I understand pjax can handle that, but can't get it to work properly.
In _form.php I have ActiveForm with widget which…

Kristīne Glode
- 1,409
- 4
- 16
- 22
5
votes
1 answer
How to remove registered jquery file in Yii2
While working with Yii2, I am facing a problem with jquery files.
In layout I have registered a jquery-1.10.2.min.js file. But in inner page
as use ActiveForm then it includes jquery file from assets as well.
Is there any way to remove…

Amit Kumar
- 3,384
- 6
- 25
- 42