# |
Nov 19th 2019, 09:46 |
noel |
Hi all. I'm working with friendsofcake/crud and jsonapi. I have a desire to create an action on a controller, which is intended to do a custom query lookup. I'm struggling to figure out how to implement this within the CRUD ecosystem. Would I have to create a custom CRUD action class and then load that as a component? Or can I just add an action function to my controller (in which case how do I make it work with crud / jsonapi)? |
# |
Nov 19th 2019, 09:43 |
slackebot |
!tias |
# |
Nov 19th 2019, 09:43 |
slackebot |
Command sent from Slack by challgren: |
# |
Nov 19th 2019, 09:43 |
dereuromark |
Try it yourself with some dangerous snippets and see. |
# |
Nov 19th 2019, 09:42 |
dereuromark |
Jep |
# |
Nov 19th 2019, 09:41 |
mehov |
> if you dont use custom query snippets that means modifying the sql directly, as opposed to using the framework-provided e.g. find or where methods, right? |
# |
Nov 19th 2019, 09:39 |
dereuromark |
If u use my tools plugin you have basic trim. That usually suffices if you dont use custom query snippets. In those cases u need more. |
# |
Nov 19th 2019, 09:37 |
dereuromark |
No it is just a wrapper. Nothing else. |
# |
Nov 19th 2019, 09:30 |
mehov |
Hi everyone, Quick question Does $this->request->getQuery('key') do any filtering/sanitization? And is it safe to put the value directly into $query->where() without any additional sanitization? (As opposed to the good old $_GET where I'm supposed to do all the sanitization myself) |
# |
Nov 19th 2019, 08:40 |
val |
I tried `allowEmptyString()`. Doesn't work for `null` |
# |
Nov 19th 2019, 08:39 |
neon1024 |
As HTML doesn’t post typed data |
# |
Nov 19th 2019, 08:39 |
neon1024 |
I would try `allowEmptyString()` as request data is usually always strings |
# |
Nov 19th 2019, 08:39 |
val |
`allowEmpty()` is deprecated :( |
# |
Nov 19th 2019, 08:39 |
neon1024 |
Although I’m unsure if `integer()` would allow a `null` |
# |
Nov 19th 2019, 08:38 |
neon1024 |
Might need both `allowEmpty` and also `integer()` |
# |
Nov 19th 2019, 08:37 |
val |
Yes something like `?int` but there is no `allowEmptyInt` |
# |
Nov 19th 2019, 08:37 |
challgren |
*Woah* _formatting_ ~options~ |
# |
Nov 19th 2019, 08:37 |
neon1024 |
If you wanted `?string` or `?int` for example |
# |
Nov 19th 2019, 08:37 |
neon1024 |
To constrain a scalar value |
# |
Nov 19th 2019, 08:36 |
neon1024 |
I belive omitting a rule would allow `null` values, as well as `allowEmpty` although some of the empty type rules have been updated in recent releases I think to be things like `allowEmptyArray` or similar |
# |
Nov 19th 2019, 08:35 |
val |
Thanks. Is there a way to allow `null` except using `allowEmpty`? |
# |
Nov 19th 2019, 08:34 |
neon1024 |
https://api.cakephp.org/3.8/class-Cake.Validation.Validator.html |
# |
Nov 19th 2019, 08:33 |
neon1024 |
@val The valiation rules are listed in the api |
# |
Nov 19th 2019, 08:33 |
neon1024 |
Ooh, did *someone* enable _formatting_ options? |
# |
Nov 19th 2019, 08:33 |
neon1024 |
Morning all |
# |
Nov 19th 2019, 08:30 |
javier.villanueva |
morning |
# |
Nov 19th 2019, 08:28 |
val |
Hi, where can I find a list of core validation rules for 3.x like https://book.cakephp.org/2/en/models/data-validation.html#core-validation-rules? |
# |
Nov 19th 2019, 07:43 |
pieceof |
> jp5421 make sure to use method:post |
# |
Nov 19th 2019, 06:44 |
conehead |
And make sure your route is setup correctly if you do not follow the standards |
# |
Nov 19th 2019, 06:43 |
conehead |
@johnpaul5421 Just use `$form->create` once and inspect the html object in your browser. You will see how the link will have to look like |
# |
Nov 18th 2019, 20:44 |
johnpaul5421 |
any ideas for the form to send the data through the action to the controller? This is without using echo $form->create and echo $form->submit('Save'); |
# |
Nov 18th 2019, 20:32 |
johnpaul5421 |
I still get object not found, The requested URL was not found on this server. error 404. |
# |
Nov 18th 2019, 20:26 |
johnpaul5421 |
sorry " " > the remainder I forgot to type. |
# |
Nov 18th 2019, 20:26 |
johnpaul5421 |
e.g. shopping_carts for ShoppingCartsController and the public function name in ShoppingCartsController is add. |
# |
Nov 18th 2019, 20:25 |
johnpaul5421 |
<form method="post" id="form" action="/shopping_carts/add |
# |
Nov 18th 2019, 20:24 |
johnpaul5421 |
thanks michaelze, I keep getting this url cannot be found on the server hmm. |
# |
Nov 18th 2019, 19:56 |
michaelze |
And maybe rethink the "not using the FormHelper" part of your question... :slightly_smiling_face: |
# |
Nov 18th 2019, 19:55 |
michaelze |
Just use the URL to your controller action as the form's action. Usually, that's /<controllername>/<action> where <controllername> is the under_scored version of the controller's name (e.g. shopping_carts for ShoppingCartsController. The <action> is just the name of the action function in your controller... |
# |
Nov 18th 2019, 19:51 |
johnpaul5421 |
Sorry, I just wanted to get some feedback. Using Cakephp 2.0, how can I submit form data from a view class to the controller without using the functions echo $form->create and echo $form->submit('Save'); My Action function is Add in the controller, which then will apply $this->RequestHandler->isAjax() or isPost. |
# |
Nov 18th 2019, 18:58 |
luizcmarin |
I saw that "file input, Kartik" was added to the cake4 update. Does anyone have any information on how to use it on cake? |
# |
Nov 18th 2019, 18:53 |
devito |
Has anyone ever used angular as the frontend and cake as the backend? Whats that experience like? |