# |
Jul 12th 2021, 19:40 |
kevin.pfeifer |
i would guess the default value shoul be present before the save is being triggered |
# |
Jul 12th 2021, 19:40 |
cnizzardini |
im surprised there is no option for this in Entity |
# |
Jul 12th 2021, 19:40 |
kevin.pfeifer |
well, i looked at the cake3 doc, not the cake4…damn google, why do you still rank 3 higher than 4 |
# |
Jul 12th 2021, 19:39 |
cnizzardini |
and set the value of its null or whatever |
# |
Jul 12th 2021, 19:39 |
cnizzardini |
you could use a beforeSave |
# |
Jul 12th 2021, 19:39 |
tyler.adam.lazenby |
I like the idea of a field rule that will be system wide to be on the model and not action specific |
# |
Jul 12th 2021, 19:39 |
tyler.adam.lazenby |
Exactly |
# |
Jul 12th 2021, 19:38 |
cnizzardini |
that seems odd, what if the entity is created elsewhere too? |
# |
Jul 12th 2021, 19:38 |
dereuromark |
It is actually EventInterface :P but no biggy |
# |
Jul 12th 2021, 19:38 |
kevin.pfeifer |
otherwise you could set the default value on the field as well i guess |
# |
Jul 12th 2021, 19:38 |
kevin.pfeifer |
so in the empty entity when your in the add function e.g. |
# |
Jul 12th 2021, 19:38 |
tyler.adam.lazenby |
really? |
# |
Jul 12th 2021, 19:38 |
kevin.pfeifer |
default values should be set in the controller as far as I know |
# |
Jul 12th 2021, 19:37 |
tyler.adam.lazenby |
yeah |
# |
Jul 12th 2021, 19:37 |
cnizzardini |
maybe the entity |
# |
Jul 12th 2021, 19:36 |
tyler.adam.lazenby |
I think this should be on the table/model but I am not sure where I would do that |
# |
Jul 12th 2021, 19:36 |
cnizzardini |
^ yes |
# |
Jul 12th 2021, 19:36 |
kevin.pfeifer |
So if no FQCN is set it tries to autoload the Event class from the point where its currently at… |
# |
Jul 12th 2021, 19:36 |
tyler.adam.lazenby |
Is there a way to specify a default value for a field? For example, a way to make it so that the system generates a token using the Security randomChar() method |
# |
Jul 12th 2021, 19:34 |
cnizzardini |
will `return false;` actually stop a save? |
# |
Jul 12th 2021, 19:34 |
kevin.pfeifer |
add `use Cake\Event\Event;` at the top |
# |
Jul 12th 2021, 19:34 |
dereuromark |
Someone should be using an IDE like phpstorm |
# |
Jul 12th 2021, 19:34 |
dereuromark |
He is just missing use statements. |
# |
Jul 12th 2021, 19:33 |
japerlman |
https://stackoverflow.com/questions/2868665/is-there-a-better-way-to-change-user-password-in-cakephp-using-auth |
# |
Jul 12th 2021, 19:33 |
japerlman |
I don't believe so no, I'm just trying to cake4 this old cake2(maybe?) example of what I'm trying to do |
# |
Jul 12th 2021, 19:33 |
kevin.pfeifer |
do you have a custom class there? |
# |
Jul 12th 2021, 19:32 |
kevin.pfeifer |
what even is `App\Model\Table\Event` |
# |
Jul 12th 2021, 19:30 |
japerlman |
4 |
# |
Jul 12th 2021, 19:30 |
kevin.pfeifer |
which cakephp version are you on? |
# |
Jul 12th 2021, 19:29 |
kevin.pfeifer |
but wait |
# |
Jul 12th 2021, 19:28 |
kevin.pfeifer |
well, use the right `use` statements |
# |
Jul 12th 2021, 19:28 |
japerlman |
```Argument 1 passed to App\Model\Table\UsersTable::beforeSave() must be an instance of App\Model\Table\Event, instance of Cake\Event\Event given``` |
# |
Jul 12th 2021, 19:28 |
japerlman |
yeah that makes it very angry. |
# |
Jul 12th 2021, 19:26 |
kevin.pfeifer |
I would say you are missing the 3 parameters that are present in that hook ```beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)``` |
# |
Jul 12th 2021, 19:25 |
japerlman |
I have that just as a troubleshooting step because beforeSave wasn't acting as I expected |
# |
Jul 12th 2021, 19:25 |
japerlman |
``` public function beforeSave() { return false; }``` |
# |
Jul 12th 2021, 19:25 |
japerlman |
I have this in my src/model/table/usertable.php and I can still edit/save users, I feel like I'm doing something very stupid and is hopefully a simple fix. |
# |
Jul 12th 2021, 19:22 |
kevin.pfeifer |
unless you manually set (or unset) the prefix |
# |
Jul 12th 2021, 19:20 |
kevin.pfeifer |
as far as I know all generated links follow the current prefix (if there is one set) |
# |
Jul 12th 2021, 18:44 |
tyler.adam.lazenby |
https://book.cakephp.org/4/en/development/routing.html#prefix-routing |
# |
Jul 12th 2021, 18:44 |
tyler.adam.lazenby |
`'prefix' => false` |