# |
Mar 25th 2019, 17:43 |
ricksaccous |
wait a minute |
# |
Mar 25th 2019, 17:43 |
ricksaccous |
only should have to do it in validator |
# |
Mar 25th 2019, 17:42 |
this.impetus |
Hrmm. I've tried using ```['Y']``` and ```['y']``` in both the view and validator, there appears to be no effect |
# |
Mar 25th 2019, 17:42 |
ricksaccous |
https://api.cakephp.org/3.7/class-Cake.Validation.Validation.html#_date |
# |
Mar 25th 2019, 17:41 |
ricksaccous |
you should also probably give smarter error messages so you know what rule got triggered |
# |
Mar 25th 2019, 17:40 |
ricksaccous |
instead of a capital Y |
# |
Mar 25th 2019, 17:40 |
ricksaccous |
i think you just need a lowercase y |
# |
Mar 25th 2019, 17:40 |
ricksaccous |
https://api.cakephp.org/3.7/class-Cake.Validation.Validator.html#_date |
# |
Mar 25th 2019, 17:39 |
ricksaccous |
you'll see that the date validator is the one triggered |
# |
Mar 25th 2019, 17:39 |
ricksaccous |
so i think the answer is pretty simple |
# |
Mar 25th 2019, 17:37 |
this.impetus |
done; added a new file to the gist, "Debug Output" |
# |
Mar 25th 2019, 17:36 |
ricksaccous |
add the resulting debug information to the gist if you want |
# |
Mar 25th 2019, 17:36 |
this.impetus |
ah. brilliant. sec. |
# |
Mar 25th 2019, 17:35 |
ricksaccous |
and that will give more information to proceed |
# |
Mar 25th 2019, 17:35 |
ricksaccous |
you should see which validation rule triggered for the year to be invalid |
# |
Mar 25th 2019, 17:35 |
ricksaccous |
exit; |
# |
Mar 25th 2019, 17:35 |
ricksaccous |
after this line debug($assignment); |
# |
Mar 25th 2019, 17:35 |
ricksaccous |
@this.impetus https://gist.github.com/jmwmulle/497103a7510ca52cb3d7f18b578a80ea#file-controller-L64 |
# |
Mar 25th 2019, 17:32 |
this.impetus |
... I am terribly sorry; assuming you're indicating a specific means of debugging, I don't know how to do that. |
# |
Mar 25th 2019, 17:31 |
ricksaccous |
have you tried debugging the entity after patching it? |
# |
Mar 25th 2019, 17:31 |
this.impetus |
yeah, ```<?=$this->Form->control('academic_year', ['type'=>'year', 'minYear'=>1950, 'maxYear'=>date('Y')]);?>``` creates a dropdown select |
# |
Mar 25th 2019, 17:31 |
ricksaccous |
@this.impetus it might be helpful to see what error is triggering, is it the integer rule that causes it to trigger? |
# |
Mar 25th 2019, 17:30 |
ricksaccous |
eh it's prob with the type year stuff |
# |
Mar 25th 2019, 17:29 |
ricksaccous |
is it working like a dropdown? |
# |
Mar 25th 2019, 17:29 |
ricksaccous |
i don't see a dropdown? |
# |
Mar 25th 2019, 17:15 |
this.impetus |
https://gist.github.com/jmwmulle/497103a7510ca52cb3d7f18b578a80ea |
# |
Mar 25th 2019, 17:13 |
this.impetus |
on it. thanks for pateince |
# |
Mar 25th 2019, 17:12 |
ricksaccous |
https://gist.github.com/ |
# |
Mar 25th 2019, 17:12 |
ricksaccous |
gist up your model, controller, and view |
# |
Mar 25th 2019, 17:12 |
this.impetus |
So the database expects a year, the form records a year, my validator expects a year... but I am getting "The provided value is invalid" on my front end. |
# |
Mar 25th 2019, 17:11 |
this.impetus |
hrmm. upon closer inspection I think I have the form set up correctly in any case: <?=$this->Form->control('academic_year', ['type'=>'year', 'minYear'=>1950, 'maxYear'=>date('Y')]);?> |
# |
Mar 25th 2019, 17:10 |
berarma |
The browser always sends strings. The entity marshaller then converts it to the database field type. |
# |
Mar 25th 2019, 17:08 |
this.impetus |
... and apparently backticks aren't how you indicate code in slack... new to this as well.. thanks for putting up wth me |
# |
Mar 25th 2019, 17:07 |
this.impetus |
I tried changing `$validator ->integer('academic_year',)` to `$validator ->date('academic_year', ['y'])` but this produced the same result |
# |
Mar 25th 2019, 17:06 |
this.impetus |
subsequently, an integer is no longer sent to the controller when a record is created, and the validator is complaining. I am certain there is some dead-simple solution here that I am missing, but I am extremely new to cake3 |
# |
Mar 25th 2019, 17:04 |
this.impetus |
*created a text field |
# |
Mar 25th 2019, 17:04 |
this.impetus |
but the baked forms, because I indicated that the year column should be an integer, created a text. When I manually edited it to create a dropdown menu listing n-years the form broke; now I get validation errors |
# |
Mar 25th 2019, 17:04 |
berarma |
I don't get the question. |
# |
Mar 25th 2019, 17:03 |
this.impetus |
when I baked it, yes |
# |
Mar 25th 2019, 17:03 |
berarma |
@this.impetus, isn't this all done automatically? |
# |
Mar 25th 2019, 16:58 |
this.impetus |
this sides = this sends, sorry |