Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#265 2008-03-27 13:57:51

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: zem_contact_reborn 4.0.3.20

When using $evaluation -> add_zemcontact_status(1); to prevent ZCR from submitting is there a way to change the error message that gets returned? I’m not using it to detect spam and I would like to give the user accurate information about why the form did not submit.

Maybe something like:

$evaluation -> add_zemcontact_status(1);
$zemErrorMsg = 'Insightful and informative error message.';

Thanks

Offline

#266 2008-03-27 14:08:57

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

If you only have one possible error message, then you can change it in zem_contact_lang.

Offline

#267 2008-03-27 18:38:08

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: zem_contact_reborn 4.0.3.20

As I thought about things a bit more I realize I was asking the wrong question. I’m not checking for spam but I do want the ability to prevent the form from submitting and to signal various errors. Is there a way to pass errors back to ZCR? (There is the possibility for multiple errors so it doesn’t seem like changing the language file is an option.)

Offline

#268 2008-03-27 19:14:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

Jason, you could do this without even editing ZCR: create a plugin that offers a tag like <txp:jdy_zem_contact_checks /> and place that tag at the end of your zem_contact form (inside the form). That way, the taghandler for that tag is called after all the earlier form tags have been processed. Since the $zem_contact_error and $zem_contact_form/values/labels arrays are globally accessible, you can read the form values/labels and use those to add errors based on the additional checks you want to perform. The tag itself should return an empty string.

Offline

#269 2008-03-27 19:55:21

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: zem_contact_reborn 4.0.3.20

Ruud, your response got me thinking a bit. Could a similar approach be used to extend the validation capabilities of ZCR with tools like checking for proper date format? How would one go about assigning checks to particular fields?

Ordinarily I’d do that kind of validation with JavaScript if I’m using ZCR, but doing it on the server has definite advantages.

Offline

#270 2008-03-27 19:57:35

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

Sure, that’s possible. Assigning checks to specific fields might be done by specifying which fields to check in the attribute of the tag that does the validating, for example: <txp:abc_zem_contact_check_date name="field1,field3" />

Offline

#271 2008-03-27 22:25:08

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: zem_contact_reborn 4.0.3.20

Thanks, Ruud. I’ll add this to my growing list of “plugins I should work on Real Soon Now.” If someone else gets to it first, then so much the better. :-)

Offline

#272 2008-03-28 02:05:03

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: zem_contact_reborn 4.0.3.20

These are probably obvious answers but I still need to ask…

1. Is there a way to tell ZCR a field has been flagged with an error so that it can be given the error class?
2. Other than checking for a specific error message within $zem_contact_error is there a way to see if a field has already triggered an error message?

I’m working on an unsubscribe function and I’m using my “preflight” function to compare a provided email address with the email addresses within a db. (I want to verify the address actually exists within the db before removing that subscriber.) I want ZCR to ensure the user has supplied a valid email address and, if so, I want to see if that email address exists within my db. In the event that an invalid email address is provided an error would be triggered by ZCR as well as my preflight function but I don’t want to return two error messages.

EDIT:
By the way, Ruud, thanks for the tip. The ability to do some preflight checks is amazing!

Last edited by jdykast (2008-03-28 02:06:46)

Offline

#273 2008-03-28 07:33:24

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

  1. yes, see the plugin help, specifically the part about styling. When an error occurs, that field gets a different class.
  2. not inside ZCR, so you’d have to remove duplicate errors manually by checking the error array.

Offline

#274 2008-03-28 12:27:59

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: zem_contact_reborn 4.0.3.20

For the answer to number 1, I think I wasn’t clear in the phrasing of the question. To keep using my example of looking for an email address, is it possible for ZCR to pass the address as valid but for my preflight to flag it with an error because it didn’t exist in the db? I understand ZCR’s ability to give a field the error class but is it possible for my preflight function to do the same? At this point I don’t see how I can do anything more than adding a message to $zem_contact_error. I don’t see how it’s possible for my function to add the error class to a field if ZCR passes it as error free.

Offline

#275 2008-03-28 15:06:11

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

Hmm.. you’re right, that isn’t possible without hacking the plugin.

Offline

#276 2008-03-29 02:20:01

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: zem_contact_reborn 4.0.3.20

At this point it’s not worth it for me to hack around with ZCR. My current use for this preflight functionality is pretty basic and I think what I have now is going to do just fine. Thanks again for the tip.

Offline

Board footer

Powered by FluxBB