Logs for #cakephp

Page 28 of 36,922, showing 100 records out of 3,692,143 total, starting on record 2,701, ending on 2,800

# At Username Text
# Jun 19th 2021, 18:46 angelxmoreno @admad did i get that right ?
# Jun 19th 2021, 18:46 angelxmoreno @kupe3b the issue is for the instructions being bad. You should still have `$this->addPlugin('Authentication');` in your Application.php file.
# Jun 19th 2021, 03:14 admad You should open an issue on the repo.
# Jun 19th 2021, 03:13 admad No
# Jun 19th 2021, 03:13 kupe3b so i dont need to add anything in bootstrap.php?
# Jun 19th 2021, 03:12 admad @kupe3b those docs are outdated.
# Jun 19th 2021, 01:41 kupe3b if i type `bin/cake plugin load pluginname` it adds `$this->addPlugin('Authentication');` in Application.php, but reading the CakeDC Users plugin i see beside addPlugin in Application.pht it also instructs adding ` ```Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);``` in bootstrap.php so i'm cofused. why do i have to add plugin twice? what is this needed?
# Jun 18th 2021, 20:35 japerlman it's because my fields are pascalCase it looks, I made a new table in all lower case and it works perfectly
# Jun 18th 2021, 19:42 japerlman PATCH url of http://x.x.x.x/roles/3
# Jun 18th 2021, 19:42 japerlman ```{ "data": { "type": "roles", "id": "3", "attributes": { "roleDescription": "My new name" } } }```
# Jun 18th 2021, 19:41 japerlman I have the json api accepting my PATCH requests now and it's returning a '200' but it's not actually updating the field in the DB with the new value, any thoughts? I've looked through the docs at https://crud-json-api.readthedocs.io/en/latest/ a few times now and it seems like my json data is valid/correct.
# Jun 18th 2021, 18:49 kevin.pfeifer well if you are happy with a search result like neon1024 explained above sure, go for that
# Jun 18th 2021, 18:40 alamnaryab @admad this datatype specification worked as I am dynamically populating conditions array, so I have made every fields string.
# Jun 18th 2021, 15:29 japerlman ok nevermind, now all my responses are blank but I'm still getting a 200 OK
# Jun 18th 2021, 15:12 japerlman I have a clean cake 4 project using the friends of cake crud plugin and the json plugin to go with it. I have the json GET requests working correctly and I'm testing my PATCH for the 'edit' action and its redirecting me back to 'index' and saying the object was updated but when I look at the object again the changes aren't there. I'm not sure why it's redirecting, I don't have any controller defined at all and just using the
# Jun 18th 2021, 15:12 slackebot1 JSON/CRUD listener so I'm not sure at all where the redirect is being defined.
# Jun 18th 2021, 12:47 admad https://api.cakephp.org/4.2/class-Cake.Database.Query.html#where()
# Jun 18th 2021, 12:46 admad `->where($conds, ['id' => 'string'])`
# Jun 18th 2021, 12:30 alamnaryab for now I managed by making an array of `int` type fields, and then inside loop `if(in_array($cols[$i],$int_typed_fileds_array))` ....
# Jun 18th 2021, 12:25 alamnaryab I am making `$conds` as below ``` $conds = []; if ( isset($qs['sSearch']) andand $qs['sSearch'] != "" ) { for ( $i=0 ; $i<count($cols) ; $i++ ) { $conds[$cols[$i]." LIKE"]="%".$qs['sSearch']."%"; } }```
# Jun 18th 2021, 12:20 kevin.pfeifer yes, but Fakhr Alam wants to set these filters dynamically and therefore tried to just make it all work with a generic ```'%field% LIKE' => '%value%', ``` which e.g. doesn’t work for integer fields
# Jun 18th 2021, 12:19 erwane I'm pretty sure the id filter should be an `=` not a `LIKE`
# Jun 18th 2021, 12:14 kevin.pfeifer @neon1024 the fact, that you didn’t continue your sequence with `101` hurt me a little…
# Jun 18th 2021, 12:07 neon1024 So if I queried for `id = 1` I would get `1`, `10`, `11`, `100`, `11011`. It’s a curious way to filter
# Jun 18th 2021, 12:05 alamnaryab because I want to do server side coding for jquery datatable filter, to check the term in all feilds
# Jun 18th 2021, 12:02 erwane if your column id is `int` why using like ?
# Jun 18th 2021, 11:23 kevin.pfeifer then I would exclude certain columns (like the id field when you have a string search param) from that search depending on what is the given search parameter type.
# Jun 18th 2021, 11:20 alamnaryab here I posted only 2 fields actually it is dynamic term to be checked in all fields of table. same as datatable search
# Jun 18th 2021, 11:15 kevin.pfeifer @alamnaryab do you really want to query the `id` column with a `LIKE`?
# Jun 18th 2021, 11:13 alamnaryab Hi All using cakephp 4.2.2 getting below error `Cannot convert value of type `string` to integer` ```$conds = [ 'id LIKE' => '%a%', //int field 'name LIKE' => '%a%', //varchar field ]; $conds= ['OR'=>$conds]; $query = $this->Students->find('all') ->where($conds) ->select($cols); $data = $this->paginate($query);```
# Jun 18th 2021, 11:08 neon1024 Hopefully shouldn’t need a template
# Jun 18th 2021, 11:08 neon1024 Yeah, I am implementing some OAuth, so just trying to get my head around the flow at the moment
# Jun 18th 2021, 11:07 kevin.pfeifer @neon1024 just FYI: If you manually return a response inside your action then you don't need to do that (like when returning ajax directly)
# Jun 18th 2021, 11:06 neon1024 Ace, thanks @kevin.pfeifer
# Jun 18th 2021, 11:05 kevin.pfeifer ```$this->autoRender = false;```
# Jun 18th 2021, 11:05 neon1024 I still get a missing template exception
# Jun 18th 2021, 11:05 neon1024 How do I disable a template render for a controller action? I’ve tried `$this->render(null)` `$this->viewBuilder->disableAutoLayout()` and `$this->viewBuilder()->setTemplate(null)`
# Jun 18th 2021, 08:38 paolo.bragagni ajax
# Jun 18th 2021, 08:10 paolo.bragagni there is a way?
# Jun 18th 2021, 08:04 paolo.bragagni hi I'm trying to get in form.twig the name of the 'title' in associated table
# Jun 18th 2021, 06:01 admad @angelxmoreno Debug if the crud action is using your table class
# Jun 18th 2021, 02:45 angelxmoreno next CRUD Q: I am on friendsofcake/crud 5.5.1 and cakephp/cakeph 3.9.10, I need help debugging why CRUD wont validate my request data https://gist.github.com/angelxmoreno/0581c7ddc95325c40fd42a9166450670
# Jun 18th 2021, 01:58 angelxmoreno @admad just wanted to follow up on your assist. Your point gave me insight and I went with a simpler solution than i originally anticipated. Route rules did the job just like you implied!
# Jun 18th 2021, 01:56 davinci I'm not sure either. :) Hoping someone here might know
# Jun 18th 2021, 01:50 bmudda Not sure you can create migration snapshot for single table. You might have to write it manually.
# Jun 18th 2021, 01:46 davinci @bmudda that seems to be talking about an entire snapshot, not a single table migration
# Jun 18th 2021, 01:45 bmudda @davinci https://book.cakephp.org/migrations/2/en/index.html#generating-migrations-from-an-existing-database
# Jun 18th 2021, 01:20 davinci (via CLI, not just by looking at it :)
# Jun 18th 2021, 01:16 davinci Can I create a migration file from an existing table?
# Jun 17th 2021, 18:41 kevin.pfeifer @joey.mukherjee well I was just referring to a belongsToMany connection, but if you are happy saving the json in your column then go for that :)
# Jun 17th 2021, 18:30 joey.mukherjee That is what I want... Neat! I'm not sure why it says something about time zones in the beginning. Thank you for the pointer!
# Jun 17th 2021, 18:26 admad https://book.cakephp.org/4/en/orm/associations.html#using-the-through-option
# Jun 17th 2021, 18:25 admad s/file type/field type
# Jun 17th 2021, 18:25 admad https://book.cakephp.org/4/en/orm/saving-data.html#saving-complex-types
# Jun 17th 2021, 18:24 joey.mukherjee @ndm I do have a junction table! Can I use that somehow? @admad That sounds useful! Is there a routine in the middle where I can modify the input/output? How do I set the file type in the schema anyway? Is that a MySQL thing? I am converting from old saved data to my new more efficient save that I would like to modify the data a bit...
# Jun 17th 2021, 18:19 admad "I save them as a json_encoded string in the database" Set the file type to "json" in table's schema, then cake will handle the string to array and array to string conversion for you
# Jun 17th 2021, 18:17 kevin.pfeifer @joey.mukherjee so you don’t have a junction table which connects your main table with the “other” table?
# Jun 17th 2021, 18:15 kevin.pfeifer I also learned new things :)
# Jun 17th 2021, 18:15 kevin.pfeifer @ndm :clap:
# Jun 17th 2021, 18:11 alamnaryab also thanks to @kevin.pfeifer and @admad
# Jun 17th 2021, 18:09 alamnaryab @ndm You are great Today in few hours I learnt too much I would like to be in your touch to learn more
# Jun 17th 2021, 18:02 joey.mukherjee I have an entity which needs an array of other entities. I save them as a json_encoded string in the database. When I load them, I want to decode the string and create all the entities. Where is the right place to do that in CakePHP? Do I create a routine in the entity of what is saved or is there something that is called whenever I retrieve/find something in the table routines?
# Jun 17th 2021, 16:14 ndm The easiest solution for you might be a redirect route (https://book.cakephp.org/4/en/development/routing.html#redirect-routing), given that you want to use use a fixed default language like in your middleware snippet, then it would just be a matter of something like `$routes->redirect('/', '/en');`
# Jun 17th 2021, 16:06 admad If you know what you are doing, no; but since you are at this for days/weeks that doesn't seem to be case for you.
# Jun 17th 2021, 16:04 alamnaryab @admad in this implementation I am not using that plugin will it be difficult to do it without plugin?
# Jun 17th 2021, 15:57 admad https://github.com/admad/cakephp-i18n#i18nmiddleware
# Jun 17th 2021, 15:52 alamnaryab what would be better event or method where I can put this redirect? app::beforeFilter()?
# Jun 17th 2021, 15:50 ndm btw, if `/` would be the only route that would have no language parameter, then I would press even harder on implementing a redirect solution, eg redirect `/` to `/default-or-browser-language`
# Jun 17th 2021, 15:49 ndm That example of course won't cover anything that you might want to in your app, you need to take a deep look at how routing works, otherwise you'll get stuck over and over again. You can connect `/` to whatever you want it to point to, like here in the first example https://book.cakephp.org/4/en/development/routing.html: `$routes->connect('/', ['controller' => 'Articles', 'action' => 'index']);`
# Jun 17th 2021, 15:44 alamnaryab that routes.php is like electric wires for me :,( what should I add at which line of this code https://cakesf.slack.com/archives/C053DPNGT/p1623931730446100
# Jun 17th 2021, 15:41 ndm Yeah, the error happens earlier, as suspected, it's missing route error... eg there is no route connected for `/` (without language parameter).
# Jun 17th 2021, 15:40 alamnaryab RoutingMiddleware is there but mine is not there named: DefaultlngMiddleware
# Jun 17th 2021, 15:37 ndm You check the stacktrace. If you don't even reach the middleware, then I guess it's a missing route error.
# Jun 17th 2021, 15:36 alamnaryab How can I check where it originates from I made the param overwritten to english in all cases, it is working because now for `en` and `ar` both is is showing english but this MiddleWare is not being executed when there is not language param
# Jun 17th 2021, 15:33 ndm Should work fine when placed afterwards with regards to be parameter being added... I'd again press on checking where exactly the error originates from then, it doesn't sound like it stems from a URL array missing the parameter.
# Jun 17th 2021, 15:31 alamnaryab also tried before RoutingMiddleware even the 1st one
# Jun 17th 2021, 15:29 alamnaryab as suggested by Mr @ndm after RoutingMiddleWare
# Jun 17th 2021, 15:24 ndm But yeah... actually, if you put it _before_ the routing middleware, the parameter would get overwritten.
# Jun 17th 2021, 15:24 kevin.pfeifer i would never
# Jun 17th 2021, 15:24 ndm Now don't you date to proof my statement wrong :)
# Jun 17th 2021, 15:21 kevin.pfeifer @alamnaryab have you added your DefaultlngMiddleware before the RoutingMiddleware?
# Jun 17th 2021, 15:18 ndm It should be. It could theoretically be misplaced order wise, but that should not affect the parameter being added. That error looks like it's not referring to a URL array. Where exactly in the code does it originate from?
# Jun 17th 2021, 15:16 alamnaryab yes it is `ResponseInterface` but looks like language param is still not added as I am still getting error `A route matching "/" could not be found.` if is not enough that debug() and exit is working in this class for adding maddleware?
# Jun 17th 2021, 15:14 ndm That snippet there looks like it should generally work. If nothing is being set, then maybe the middleware hasn't been added (correctly).
# Jun 17th 2021, 15:12 ndm See the return type hint of the method, you must return a response.
# Jun 17th 2021, 15:07 alamnaryab From `MiddlewareClass` should I return `$request` or `$response` both not adding language parameter, am I doing any mistake also tried commented `return $response`
# Jun 17th 2021, 14:52 ndm @alamnaryab You don't need to care about the debug output structure, you use the public API provided by the object. Not sure where you got `addParam()` from, in 4.x you'd use `withParam()` (https://api.cakephp.org/4.2/class-Cake.Http.ServerRequest.html#withParam()), and have to reassign the returned object as it is immutable (https://book.cakephp.org/3/en/controllers/request-response.html#common-mistakes-with-immutable-responses same
# Jun 17th 2021, 14:52 slackebot applies to requests). Trying to get this working is a good exercise, however I'd still suggest that you consider the redirect solution.
# Jun 17th 2021, 14:38 alamnaryab I have create class as shown in documentation also added in middlewareQueue in application.php how can I modify request params it is protected scoped
# Jun 17th 2021, 14:05 admad I must them done them on 4.next just to be safe, didn't remember for which branch/release i had done the changes :)
# Jun 17th 2021, 13:59 erwane Mailer ```public function viewBuilder(): ViewBuilder { $builder = parent::viewBuilder(); $builder->setClassName('Mailer'); return $builder; }``` And View ``` class MailerView extends View { /** * @inheritDoc */ public function __construct( ?ServerRequest $request = null, ?Response $response = null, ?EventManager $eventManager = null, array
# Jun 17th 2021, 13:59 slackebot $viewOptions = [] ) { parent::__construct($request, $response, $eventManager, $viewOptions); $this->setSubDir(I18n::getLocale()); } }``` Thanks.
# Jun 17th 2021, 13:56 dantedantas Thank you very much Kevin. I will look and test everything that you sent to me.
# Jun 17th 2021, 13:55 ndm @alamnaryab You can either create a custom class (https://book.cakephp.org/4/en/controllers/middleware.html#creating-middleware), or use a callable (it receives the same arguments as the `MiddlewareInterface::process()` method).
# Jun 17th 2021, 13:54 erwane Thanks. yes, i can pass it in template path, but i'm looking for a more generic way, just pass the template, Locale is "another logic". I will create a "MailerView"
# Jun 17th 2021, 13:52 ndm @erwane I don't think `setOptions()` will work, if it's not in `$_passedVars`, then you can't pass it via the view builder. However you should be able to achieve the same result by modifying the template path accordingly.
# Jun 17th 2021, 13:49 alamnaryab @ndm I do not know how to add my custom code or logic like this in middleware currently I can see only chained add functions to middleware queue.
# Jun 17th 2021, 13:47 erwane Hi, I'm trying to create email with localized templates. The `View` has subDir option now, perfect, but this option is not in ``` /** * List of variables to collect from the associated controller. * * @var string[] */ protected $_passedVars = [ 'viewVars', 'autoLayout', 'helpers', 'template', 'layout', 'name', 'theme', 'layoutPath', 'templatePath', 'plugin', ];``` We can't define
# Jun 17th 2021, 13:47 slackebot `View::$subDir` through viewBuilder()->setOption() ?
# Jun 17th 2021, 13:45 ndm Make sure that the middleware is added _after_ the routing middleware, otherwise the parameters will never be present.