Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filetype enum validation #16

Closed
cristiandavidgm opened this issue Oct 3, 2012 · 3 comments
Closed

Filetype enum validation #16

cristiandavidgm opened this issue Oct 3, 2012 · 3 comments
Assignees

Comments

@cristiandavidgm
Copy link

First, I would like to say that your work is awesome!

Second, I am having troubles whit enum fields, The program (untouched) return:

{"success":false,"message":"Please check the form for errors","errors":{"jobStatus":"JobStatus:open exceeds the maximum length of openclosedpendingstalled","postedBy":"PostedBy:admin exceeds the maximum length of tenantadminowner","propertyMultiUnitsId":"PropertyMultiUnitsId is not a valid number","priority":"Priority:urgent exceeds the maximum length of urgenthighmediumlow"}}

And if I look into de the code I see this:

//Generated code

  1. $fm["JobStatus"] = new FieldMap("JobStatus","REPM_jobs","job_status",false,FM_TYPE_ENUM,'open'.'closed'.'pending'.'stalled',"open",false);

//FiledMap.php
2. public function __construct($pn, $tn, $cn, $pk = false, $ft = FM_TYPE_UNKNOWN, $fs = 0, $dv = null, $iai = null)

Phreezable.php
3. if ($fm->FieldSize && (strlen($this->$prop) > $fm->FieldSize))
{
$this->AddValidationError($prop,"$prop exceeds the maximum length of " . $fm->FieldSize . "");
}

So, I think you are sending a string where there should be a number, and there is not a base validation for the enum type field.

Thx
Cristian David.

@ghost ghost assigned jasonhinkle Oct 3, 2012
@jasonhinkle
Copy link
Owner

Ah I see what is happening. In the meantime until I can get that fixed properly, you could fix your generated app by replacing

'open'.'closed'.'pending'.'stalled'

with a max-size number for the column.

I think what really should happen for enum columns is that Phreeze should generate a drop-down for that field with the appropriate values and then perhaps on the back-end validate them as well.

@jasonhinkle
Copy link
Owner

ok enum types are now supported and generated correctly in commit a4b2fc6. If you update Phreeze and regenerate the files in your libs/Model/DAO/ folder then you should get proper validation. I didn't update the generator to provide a drop-down yet, but i'll get to that.

@jasonhinkle
Copy link
Owner

cleaning up the tracker, I think this is resolved - if not please re-open. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants