Gossamer Forum
Home : Products : Links 2.0 : Customization :

What's the variable ctng. add error messages?

Quote Reply
What's the variable ctng. add error messages?
Hello world!

Assume I want to show up with a large red X in which field on the "add a site"-page the user made a wrong entry, what's the variable that contains the respective error message for each of the fields?

So far I tried out stuff like $err{'Title'} or $col{'Title'} (to find out if there's an error in the title-form-entry), but it didn't work.

Can someone help out?

Thanks
Denis
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
You will still have to use the record hash ($rec) for the field, but you need to set up a list of conditional statements, like the following:

Code:
if ($rec{'Title'} =~ /^\s$err/) {
$errmsg .= qq~<font color="ff0000"><b>X</b></font>~;
}

in the sub site_html_add_failure routine in the site_html.pl file.

Then include the $errmsg variable in the HTML codes, like the following:

Code:
~;
if ($errmsg) {
print qq~Title $errmsg~;
}
else {
print qq~Title~;
}

These are just example codes of the direction where you need to go.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
Thanks Eliot, will try out that way...
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
You're welcome...Again, I don't gaurantee it will work...and make sure that you make a backup of your site_html.pl file before making this modification.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
Ok, now I've tried 1 hour, but no outcome.

What I don't understand about your codes (because I've no idea what it actually means/does) is this
Code:
=~ /^\s$err/
You made no mistake in there? I can't check it with my knowledge.

All other combinations I've tried out, I believe. When I 'translate' your codes you say 'if the entry for the title of a record contains an error, setup $errmsg to show a red "X". Ok, that's fine. But since there can be more than one field with an error in it at a time, I could use some $errmsg1, $errmsg2, ... to differ between the possibilities.
But that's the next step, first of all it's not showing any X when I leave the Title-field blank.

One more thing: what's the reason you want to set up $rec at the top of the sub and later on say if it contains a value than print X and if not just print Title? Couldn't I put this in just one if clause saying 'if there's something print it, if not - not'?.

Hm, hope you get the points out of my bla bla.

Denis

Btw: the script already does what I want to do in some way: it says for example Title - cannot be left blank only in case the title is left blank. I could change this sentence to say X only, delete the stuff with the <li> listing and set each errormessage to one variable containing its X and then say something like if ($variable_for_title_error ne "") {print qq~$variable_for_title_error~;}. And then a big large red X would show the user the place where he made his mistake in the add-form.
But I'd really miss the nice 'cannot be left blank' note at the top. Therefore I took a look at db_utils.pl where I've found the 'cannot be left ...'-stuff - but all being put in a list here:
Code:
if ($#input_err+1 > 0) { # since there are errors, let's build
foreach $err (@input_err) { # a string listing the errors
$errstr .= "<li>$err"; # and return it.
}
return "<ul>$errstr</ul>";
and I wasn't able to figure out how to extract each single error out of the $errstr.


Cool, that's a lot bla bla Wink

[This message has been edited by Denis (edited March 16, 2000).]
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
[..]

This is still unsolved. Any ideas?
Only thing I'd need is the exact variable to address with an if-clause in order to find out in which of the add-fields mistakes have been made...
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
[..]
Smile
Quote Reply
Re: What's the variable ctng. add error messages? In reply to
Welp, Denis...now that you have a Perl book, you should be able to figure out what the codes mean and do...

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums