Hi folks,
Now I do a website with users invitation system. Administrator sends an invitation and once it’s done, user can register by link in the email he received. That is not important Just an intro…
So, I’ve done a form with appropriate fields and I want it to work with AJAX. So, I’ve placed CHtml::ajaxSubmitButton
Everything works, but what if I want to update a couple of blocks before and after the form? How can I do that? Also, if something is entered wrong (e-mail does not pass validation (CEmailValidation)) I’d like to highlight misstaken fields… How can I do it?
In controller (/admin/users/invite):
if (Yii::app()->request->isAjaxRequest)
{
$invite = new invite;
$invite->attributes = $_POST['invite'];
$mailer = Yii::app()->mailer;
$mailer->IsSMTP();
$mailer->AddAddress('does not matter', 'does not matter');
$mailer->Subject = "does not matter";
$mailer->Body = "does not matter";
if (!$mailer->Send())
echo "Could not send e-mail";
if ($invite->save())
print "<br /> SUCCESS";
else print CHtml::errorSummary($invite);
return true;
}
In the form:
<?php echo CHtml::ajaxSubmitButton('Send', array('/admin/users/invite'), array('update'=>'#tx')); ?>
<p id='tx'></p><p id='px'></p>
So, now I update just #tx… But I would like to update #px as well… Can I do it using only Yii mechanisms? If not, I will write an extension for my beloved XAJAX.