Geoff
Geoff

Reputation: 6639

Adding properties to the form in yii2

Am adding properties to the active form but it isn't working

Am using a wbranca's dynamic form that needs to pass a form id in the begin form and also in the same form there is a file uploader that requires'options' => ['enctype' => 'multipart/form-data'

I have tried 
 <?php $form = ActiveForm::begin(['id' => 'dynamic-form']
,['options' => ['enctype' => 'multipart/form-data']]); ?>
the form cant upload

When I interchange the two like below the form id is not rendered so the dynamic forms can't work

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

Upvotes: 0

Views: 686

Answers (1)

Nana Partykar
Nana Partykar

Reputation: 10548

In your code ;

<?php $form = ActiveForm::begin['options' => ['enctype' => 'multipart/form-data'],,(['id' => 'dynamic-form']]); ?>
  • You have not open bracket '(' after ActiveForm::begin.
  • 2 Comma used between form-data'],,(['id'
  • Unnecessary used '()' in 'id' part. And, didn't closed properly.

Use this. It will work

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

Upvotes: 3

Related Questions