|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Quickform general error echoing
Hi,
I'd like to ask a PHP+Pear Quickform question. The input fields of the website were built up with QF, and all of it has a SetElementError. After you submit, and error happens, then the errors will show up by GetElementError. The question is the following, I'd like to solve that if any error happens, then PHP and/or QF will show an error message as well. I need it because the form is a bit long, more one page, and if the single error is on the bottom of the page, the user won't understand, why he/she got back to the form. So I'd like to echo an error message on the top of the page, after the user clicked on the submit button, and any error happened. thanks, nm |
|
#2
|
|||
|
|||
|
And what is your question? I don't see a question in your post.
But you're likely wanting to use something like this: if ($form->isSubmitted() && !$form->validate()) { echo '<p>Please correct the following errors.</p>'; } |
|
#3
|
|||
|
|||
|
Quote:
You're right, I'd like to make something like this. The only problem is the following: PHP Code:
When I load the page, it automatically shows "something" above the form. How can this be fixed, so "something" should appear only after when the submit button is clicked (but on the same pages as the form)? thanks. |
|
#4
|
|||
|
|||
|
$form->isSubmitted() (as the name of the method indicates) is only true if the form was submitted. Therefore, you could split my example code, e.g. like this:
if ($form->isSubmitted() { __echo 'something'; __if (!$form->validate()) { ____echo '<p>Please correct the following errors.</p>'; __} } (_ is used here because I don't know how to use intendation and highlighting here) |
|
#5
|
|||
|
|||
|
Quote:
Thanks your help, I could extend my code with this. regards, nm |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Quickform general error echoing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|