In Yii I am doing a form in which the form has input fields for user details.I have made necessary input fields for all those fields.Where a user can submit all the values.Now I have a field where it will show the form number which will not be entered by user.It will be generated randomly with ascending order like
for the 1st form it will be like this FORM:001,
For the second form it will be like this FORM:002
and it will go on.
Now I want that the form number will be like Form:001
so how to do that?HAny help and suggestions will be highly appriciable.
[UPDATED]
<div class="row">
<?php echo $form->labelEx($model,'id'); ?>
<?php echo Yii::app()->db->getLastInsertId();?>
<?php echo $form->error($model,'id'); ?>
</div>
This is the code for view > _form.php file.
and the result is ID 0
What you need is either of the following:
or alternatively run the following after the insert, and only display the form id then:
UPDATE:
On the above:
automatically gives you the last ID inserted so you can just put the following in your view: