in Yii, if you are adding custom fields to forms, you need to add model name to the input fields like this:
<input name="ModelName[fieldname]"/>
here, you have access to $model, but, from this, you cannot get the model name.
Simply use PHP's get_class() method to do this:
$ModelName = get_class($model);
So, the final code should be:
<input name="<?php echo $ModelName;?>[fieldname]"/>
<input name="ModelName[fieldname]"/>
here, you have access to $model, but, from this, you cannot get the model name.
Simply use PHP's get_class() method to do this:
$ModelName = get_class($model);
So, the final code should be:
<input name="<?php echo $ModelName;?>[fieldname]"/>
No comments:
Post a Comment