how to return a form widget in a components or else?

I wrote a comment module to CURD comments independent. So I write a static public function in CommentModule class

like following, then we can call the API in the view to generate a comment form anywhere.




static public function getCommentForm($object,$parent_id=0)

    {   

        $object_type = self::getObjectType($object);

        $object_id = self::getObjectId($object);

        $commentModel = new Comment;

        $commentForm = new CForm(array(

                    'activeForm' => array(

                        'class' => 'CActiveForm',

                        'enableAjaxValidation' => true,

                        'id' => 'comment-form',

                        ),  

                    'action'=>'/xcomment/create',

                    'elements'=>array(

                        'object_id'=>array(

                            'type'=>'hidden',

                            'value'=>$object_id,

                            ),  

                        'object_type'=>array(

                            'type'=>'hidden',

                            'value'=>$object_type,

                            ),  

                        'parent_id'=>array(

                            'type'=>'hidden',

                            'value'=>$parent_id,

                            ),  

                        'content'=>array(

                            'type'=>'textarea',

                            ),  

                        ),  

                    'showErrorSummary'=>true,

                    'buttons'=>array(

                        'submit'=>array(

                            'type'=>'submit',

                            'label'=>'submit',

                            ),  

                        ),  

                    ), $commentModel);    

        return $commentForm;

    }  



Then I have use echo in the view

<?php echo Yii::app()->getModule(‘xcomment’)->getCommentForm($model);?>

and $form->render() not working.

But enableAjaxValidation not working.

maybe this is not the pactise to return a Form in module,

what’s your option about this?

Actually,I wanna return a widgets,but I don’t know how to do.

Who can point out the right way for me :lol: