Hi all,
I have a contact form which users can fill up and have their message
sent via email. There's a ContactAction with an executeWrite() method
and three views: Input, Error and Success. There's also a validator
for the contact form.
When the form is submitted without the necessary values, the
ContactErrorView is called. Within this, I'm setting the template back
to ContactInput so that the initial form is redisplayed with error
messages:
public function executeHtml(AgaviRequestDataHolder $rd)
{
$this->setupHtml($rd);
$this->getLayer('content')->setTemplate('ContactInput');
}
This works fine. What I'm trying to figure out is, how do I handle a
situation where the form is correctly filled but the message is not
sent. I'll know when this happens because mail() will return false,
but I'm not sure how to catch it and display a page saying 'your
message could not be sent'. If I check the return value of mail() in
the ContactAction::executeWrite() method and return 'Error', it simply
returns the input form again.
Do I need another error view - maybe ContactSendError - and do something like:
if (mail error) {
return 'SendError';
} else {
return 'Success';
}
Or is there a better way?
TIA,
Vikram
_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users