ckroon
Posts: 869
|
| Posted: 04/05/2008, 9:11 AM |
|
Hi All...
I pieced together some code after scoring the Message forum and came up with what I thought was good code. But I can't get it to go. T_object operator error keeps popping up.
I am trying to make it mandatory that a user enters a "reason" if the grade is C or below
Here is what I got. I'm close!...
$gradetable->grade->GetValue();
if ($gradetable->grade->GetValue() >="C"&&(gradetable->reason->GetValue())=="")
$gradetable->AddErrors("Must have a reason for grades lower than C.")
Thanks!
_________________
Walter Kempees...you are dearly missed. |
 |
 |
DonP
|
| Posted: 04/05/2008, 11:43 AM |
|
The problem is that "C" is not a value that can be more than or less
than but if you can change it to a numeric value, try something like this:
if (!$gradetable->reason->GetValue() && $gradetable->grade->GetValue()
<= 3) {
$gradetable->AddErrors("Must have a reason for grades lower than C.");
}
If you cannot change it to numeric, then you'll have to add each grade
letter to the conditional.
if (!$gradetable->reason->GetValue() && ($gradetable->grade->GetValue()
== "C" || $gradetable->grade->GetValue() == "D" ||
$gradetable->grade->GetValue() == "F")) {
$gradetable->AddErrors("Must have a reason for grades lower than C.");
}
Don (DonP)
ckroon wrote:
> Hi All...
>
> I pieced together some code after scoring the Message forum and came up with
> what I thought was good code. But I can't get it to go. T_object operator error
> keeps popping up.
> I am trying to make it mandatory that a user enters a "reason" if the grade is
> C or below
>
> Here is what I got. I'm close!...
>
> $gradetable->grade->GetValue();
> if ($gradetable->grade->GetValue()
>> ="C"&&(gradetable->reason->GetValue())=="")
> $gradetable->AddErrors("Must have a reason for grades lower than C.")
>
> Thanks!
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
ckroon
Posts: 869
|
| Posted: 04/05/2008, 1:07 PM |
|
Thanks Don!
_________________
Walter Kempees...you are dearly missed. |
 |
 |
ckroon
Posts: 869
|
| Posted: 04/06/2008, 3:23 PM |
|
Edited to this:
f (!$gradetable->reason->GetValue() && ($gradetable->grade->GetValue()
== "C" || $gradetable->grade->GetValue() == "D" ||
$gradetable->grade->GetValue() == "F")) {
$gradetable->errors->adderror("Must have a reason for grades lower than C.");
}
It works great!
Thanks DOn!
_________________
Walter Kempees...you are dearly missed. |
 |
 |