I have a form which submits to the same page, how can I make it clear the input fields after it has been submitted? I want to output the flash message at the top of the page and reset the original form fields.
I have a form which submits to the same page, how can I make it clear the input fields after it has been submitted? I want to output the flash message at the top of the page and reset the original form fields.
Anyone able to advise?
BUMP!
before render try this:
$YourFormInstance->attributes = array();
Like this?
$callback=new CallbackForm;
if(isset($_POST['CallbackForm']))
{
$callback->attributes=$_POST['CallbackForm'];
if($callback->validate())
{
$callback->attributes = array();
Yii::app()->user->setFlash('callback','Thank you for your request. We will contact you as soon as possible.');
}
}
It didn’t work…
$callback=new CallbackForm;
if(isset($_POST['CallbackForm']))
{
$callback->attributes=$_POST['CallbackForm'];
if($callback->validate())
{
//$callback->save(); ??
$callback = new CallbackForm;
Yii::app()->user->setFlash('callback','Thank you for your request. We will contact you as soon as possible.');
}
}