Yii - 如何提交表单并将用户发送到给定的锚点?

I need to achieve in Yii something like this:

<form action="somescript.php#fragment-id">

Once the form get's submitted, the success message should appear in front of the user eyes. At this time, the message is displaying BUT, the browser goes back to the top.

<?php $form=$this->beginWidget('CActiveForm', array(
                    'id'=>'contact-form',
                    'enableClientValidation'=>true,
                )); ?>

  //form here
  <?php echo CHtml::submitButton('send')); ?>

<?php $this->endWidget(); ?>

I see something here called actionPrefix, but it seems to be coming from another class:

CWidget

http://www.yiiframework.com/doc/api/1.1/CActiveForm

I've tried to add actionPrefix like so:

<?php $form=$this->beginWidget('CActiveForm', array(
                    'id'=>'contact-form',
                    'enableClientValidation'=>true,
                    'actionPrefix'=>'fragment-id'
                )); ?>

No dice.

Please advice

In the controller/action that receives your form submit, once the form is processed, simply redirect to the URL you want. eg:

$this->redirect(Yii::app()->request->baseUrl."/myurl#fragment-id");

You can even get real fancy and use this short jQuery scroll to function:

function goToByScroll(id){
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

Which get's called like so:

goToByScroll("theIdIWantToGoTo");

Use the action attribute of CActiveForm. repalce 'controller/acion' with your specific needs.

  <?php $form=$this->beginWidget('CActiveForm', array(
                        'id'=>'contact-form',
                        'enableClientValidation'=>true,
                        'action'=>array('controller/acion','#'=>'fragment-id')
                    )); ?>

You are looking at the wrong option. what you need its action:

<?php $form=$this->beginWidget('CActiveForm', array(
                    'id'=>'contact-form',
                    'action'=>$this->createUrl('')."#fragment-id",
                    'enableClientValidation'=>true,
                )); ?>

  //form here
  <?php echo CHtml::submitButton('send')); ?>

<?php $this->endWidget(); ?>

The empty params for the createUrl its to generate an URL for the ccurrently requested URL