title: Yii2 : How to generate User ID from given string in Yii2?
body: <pre><code>&lt;?php $form = ActiveForm::begin(); ?&gt; 
  &lt;?= Html::activeHiddenInput($model, 'client_code', ['value' =&gt; $result ])?&gt;
              &lt;?php
                  $myStr  = $model =&gt; 'comany_name';
                  $result = date("m-d") . "";
                  for($i=0; $i&lt;5; $i++) {
                      $result .= $myStr[$i];
                  }
                  echo $result ;
              ?&gt; 
     &lt;?= $form-&gt;field($model, 'company_name')-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
      &lt;div class="form-group"&gt;
  &lt;?= Html::submitButton($model-&gt;isNewRecord ? 'Create' : 'Update', ['class' =&gt; $model-&gt;isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?&gt;
          &lt;/div&gt;
          &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  
  <p>Its my form I want to create client code from company name and current date. on submit in client_code field it should get result of first five letters from company_name field + date(day &amp; month)</p>
  
  <p>Controller-</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>public function actionUpdate($id)
      {
          $model = $this-&gt;findModel($id);
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('update', [
                  'model' =&gt; $model,
              ]);
          }
      }
  </code></pre>
  
  <p><strong>Create</strong></p>
  
  <pre><code> public function actionCreate()
      {
          $model = new CreateClient();
          $employee = new Employee();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) 
          {
              $model-&gt;save();
  
               $employee-&gt;attributes = $model-&gt;attributes;
               $employee-&gt;save();
  
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } 
          else 
          {
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
                  'employee' =&gt; $employee,
  
              ]);
          }
      }
  </code></pre>