<?php
/**
 * @var \yii\db\ActiveRecord $model
 * @var array $types
 */

use yii\helpers\Html;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin([
	'id' => 'dynamic-form',
	'enableAjaxValidation'   => false,
	'enableClientValidation' => true,
]);
foreach ($this->context->module->attributes as $field) {
	if (isset($types[$field])) {
		$function = $types[$field]['type'];
		echo $form->field($model, $field)
			->$function(
				$types[$field]['options']
			);
	} else {
		echo $form->field($model, $field);
	}

}

echo Html::submitButton();

$form = ActiveForm::end();
