Questions tagged [active-form]

ActiveForm is a widget that builds an interactive HTML form for one or multiple data models.

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.
18
votes
4 answers

yii2 ActiveForm numeric textfield

I've created an ActiveForm using yii2 like this: 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. 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. 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 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: