# |
Mar 25th 2019, 17:50 |
ricksaccous |
cakephp does something special with it's datetime selects but the magic only works for datetime fields i think |
# |
Mar 25th 2019, 17:49 |
ricksaccous |
yeah, but it should be a string not an array like that |
# |
Mar 25th 2019, 17:49 |
this.impetus |
hrmm the year value does seem to be read, tho: ```/src/Controller/AssignmentsController.php (line 64) [ 'cvsection_id' => '3', 'cvsubsection_id' => '1', 'servicerole_id' => '3', 'institution_id' => '1', 'description' => 'asdfasdf', 'academic_year' => [ 'year' => '2010' ], 'scv' => '0' ]``` |
# |
Mar 25th 2019, 17:48 |
this.impetus |
lul |
# |
Mar 25th 2019, 17:48 |
ricksaccous |
;) |
# |
Mar 25th 2019, 17:48 |
ricksaccous |
getRequest()->getData() |
# |
Mar 25th 2019, 17:48 |
ricksaccous |
you need to do |
# |
Mar 25th 2019, 17:48 |
this.impetus |
``` if ($this->request->is('post')) { debug($this->getRequest->getData()); exit(); $assignment = $this->Assignments->patchEntity($assignment, $this->request->getData()); ``` throws ``` Call to a member function getData() on boolean``` |
# |
Mar 25th 2019, 17:48 |
ricksaccous |
you can just do $this->Form->control('academic_year', [ 'options' => $arrayOfYearOptions, 'empty' => true]); or something |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
you probably shouldn't use that form control |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
lol |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
i have a feeling you are passing the academic year as an array |
# |
Mar 25th 2019, 17:47 |
this.impetus |
kk |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
debug that before you patch |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
yeah, you can customize them |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
debug $this->getRequest->getData(); |
# |
Mar 25th 2019, 17:47 |
this.impetus |
to be honest that makes me feel significantly better :P the error message, sadly, is also baked in |
# |
Mar 25th 2019, 17:47 |
ricksaccous |
can you |
# |
Mar 25th 2019, 17:46 |
ricksaccous |
i'm not even sure about the default way this works, lol damn |
# |
Mar 25th 2019, 17:46 |
ricksaccous |
wait |
# |
Mar 25th 2019, 17:46 |
ricksaccous |
look at the 'dirty' fields of your entity |
# |
Mar 25th 2019, 17:44 |
this.impetus |
How's that? lines 15 and 41 in the entity both refer to 'academic_year' |
# |
Mar 25th 2019, 17:44 |
ricksaccous |
it's not even in your assignment entity |
# |
Mar 25th 2019, 17:44 |
ricksaccous |
it's not being passed in |
# |
Mar 25th 2019, 17:43 |
ricksaccous |
you're date value isn't even being read |
# |
Mar 25th 2019, 17:43 |
ricksaccous |
lol |
# |
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 |