# |
Feb 3rd 2018, 17:18 |
sayed |
no |
# |
Feb 3rd 2018, 17:18 |
sayed |
File uploaded https://cakesf.slack.com/files/U8SE5F2NN/F949JJQ0N/screen_shot_2018-02-03_at_18.17.37.png / https://slack-files.com/T053DPNCM-F949JJQ0N-52f86cc5e9 |
# |
Feb 3rd 2018, 17:17 |
hmic |
is the guid setup as the primarykey for that table too? |
# |
Feb 3rd 2018, 17:17 |
sayed |
field |
# |
Feb 3rd 2018, 17:16 |
sayed |
and oww yeah unique also works on the emailadres |
# |
Feb 3rd 2018, 17:16 |
sayed |
``` public function buildRules(RulesChecker $rules) { $rules->add($rules->isUnique(['guid'])); $rules->add($rules->isUnique(['emailadres'])); return $rules; } ``` |
# |
Feb 3rd 2018, 17:16 |
sayed |
yes |
# |
Feb 3rd 2018, 17:16 |
hmic |
do you have rules setup too, for the validateunique to work? |
# |
Feb 3rd 2018, 17:16 |
sayed |
Any ideas ? |
# |
Feb 3rd 2018, 17:16 |
sayed |
but not for unique, it just goes through and mysql itself gives out an error, since the column is marked as unique |
# |
Feb 3rd 2018, 17:15 |
sayed |
and the thing that i really dont get is, if i for example leave the `guid` field empty, it does validates it as required |
# |
Feb 3rd 2018, 17:14 |
sayed |
but it passes through |
# |
Feb 3rd 2018, 17:14 |
sayed |
In my users table i am clearly checking the item with the validator |
# |
Feb 3rd 2018, 17:14 |
sayed |
``` $validator ->scalar('guid') ->maxLength('guid', 255) ->requirePresence('guid', 'create') ->notEmpty('guid') ->add('guid', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']); ``` |
# |
Feb 3rd 2018, 17:13 |
sayed |
``` { "message": "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry \u0027290b0b55-01fc-4c7e-a8b8-1234234\u0027 for key \u0027guid\u0027", "url": "\/api\/users\/add", "code": 500, "file": "\/Users\/sayedshahidi\/sites\/rendement\/vendor\/cakephp\/cakephp\/src\/Database\/Statement\/MysqlStatement.php", "line": 39 } ``` |
# |
Feb 3rd 2018, 17:13 |
sayed |
``` |
# |
Feb 3rd 2018, 17:12 |
sayed |
fields * |
# |
Feb 3rd 2018, 17:12 |
sayed |
It does works in the case of other fiels |
# |
Feb 3rd 2018, 17:11 |
hmic |
whats the error |
# |
Feb 3rd 2018, 17:11 |
sayed |
Hi guys, i have a problem with the validation process of an entity. For some reason the cakephp 3 validator passes through the validation process, and it is the mysql that gives out the error on save. |
# |
Feb 3rd 2018, 16:26 |
admad |
yup |
# |
Feb 3rd 2018, 16:20 |
hmic |
but i can add that to be pulled out of my provided config easily myself |
# |
Feb 3rd 2018, 16:19 |
hmic |
:-) |
# |
Feb 3rd 2018, 16:19 |
hmic |
as i try to just throw it in the mix, without writing *any* code for it to work as a backend |
# |
Feb 3rd 2018, 16:19 |
hmic |
i actually think thats a good feature, especially for crudview |
# |
Feb 3rd 2018, 16:03 |
admad |
thought about it but don't want to go about stuffing too much in global config |
# |
Feb 3rd 2018, 16:02 |
hmic |
can't specify it in the crud.php config even? :D |
# |
Feb 3rd 2018, 16:02 |
hmic |
sounds reasonable ;-) |
# |
Feb 3rd 2018, 15:59 |
admad |
all you should need is: $this->viewBuilder->setHelpers([ 'CrudView' => [ 'className' => 'CrudView.CrudView', 'fieldFormatters' => [ 'datetime' => function () {..} ] ] ]); |
# |
Feb 3rd 2018, 15:58 |
admad |
just extra safety to ensure the view's beforeLayout to run before any helper's beforeLayout |
# |
Feb 3rd 2018, 15:57 |
hmic |
i see you did set a priority on the event - probably for (that?) reason |
# |
Feb 3rd 2018, 15:57 |
hmic |
the htmlhelper got loaded differently though, i think the prg component injected it in an event that screwed things up badly |
# |
Feb 3rd 2018, 15:56 |
hmic |
that was the idea, yeah |
# |
Feb 3rd 2018, 15:55 |
admad |
i have taken care of that :slightly_smiling_face: For the use case you explained earlier you just need to configure the helper through view builder in controller, don't need to extend everything |
# |
Feb 3rd 2018, 15:54 |
hmic |
which resulted in a fatal error in the helperregistry checkduplicate method |
# |
Feb 3rd 2018, 15:54 |
hmic |
so that the array_merge would have an array like: [0 => 'Html', 'Html' => ['className'] ...]] |
# |
Feb 3rd 2018, 15:53 |
hmic |
at least i run into a problem where the htmlhelper got loaded before here: https://github.com/FriendsOfCake/crud-view/pull/231/files#diff-117e49cbe8d9eb7722b105868b236b4eR133 |
# |
Feb 3rd 2018, 15:53 |
hmic |
but i'm not quite certain if it will work in all the wired circumstances i tried to extend the helper and view... |
# |
Feb 3rd 2018, 15:52 |
hmic |
it will certainly fix my problem |
# |
Feb 3rd 2018, 15:52 |
hmic |
looks good at first sight |
# |
Feb 3rd 2018, 15:39 |
admad |
hmic: https://github.com/FriendsOfCake/crud-view/pull/231 |