M
M
mrsbennet2019-08-21 10:33:49
Yii
mrsbennet, 2019-08-21 10:33:49

How to generate custom .html form in yii?

The form

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Form</title>
    <link href="assets/css/formstyle.css" rel="stylesheet">
  </head>
  <body>
    <div class="container">  
          <form id="contact" action="index.php" method="post">
    		<h3>Добро пожаловать!</h3>
    		<h4>Ниже вы можете оставить информацию о себе и мы свяжемся с вами в ближайшее время:)</h4>
    			<fieldset>
     				 <input name="name" placeholder="Ваше имя" type="text" tabindex="1" required autofocus>
   				 </fieldset>
   				 <fieldset>
     				 <input name="lastname" placeholder="Ваша фамилия" type="text" tabindex="1" required autofocus>
   				 </fieldset>
   				 <fieldset>
     				 <input name="post" placeholder="Ваша почта" type="email" tabindex="2" required>
    			</fieldset>
    			<fieldset>
     				 <input name="telephone" placeholder="Ваш телефон" type="tel" tabindex="3" required>
    			</fieldset>
    			<fieldset>
     				 <input name="skype" placeholder="Ваш Skype аккаунт" type="text" tabindex="3">
    			</fieldset>
    			<fieldset>
     				 <textarea name="content" placeholder="Есть ли у вас вопросы?" tabindex="5"></textarea>
    			</fieldset>
   				 <fieldset>
      				<input class='button' name="submit" type="submit" id="contact-submit" data-submit="...Отправка" value="Отправить">
   				 </fieldset>
 		  </form>  
     	</div>
  </body>
</html>

Form yii
<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\FormSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Forms';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="form-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Create Form', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'name',
            'surname',
            'phone',
            'email:email',
            //'content:ntext',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>


</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question