Logs for #cakephp

Page 46 of 36,922, showing 100 records out of 3,692,143 total, starting on record 4,501, ending on 4,600

# At Username Text
# May 26th 2021, 21:59 tyler.adam.lazenby ```// label specific for radio 'radiolabel' => '<label class="form-check-label" {{attrs}}>{{text}}</label>', // Wrapping container for radio input/label, 'radioWrapper' => '<div class="form-check form-check-radio">Boo {{radiolabel}}</div>',```
# May 26th 2021, 21:59 tyler.adam.lazenby this is what i am trying right now in my custom FormHelper class
# May 26th 2021, 21:59 tyler.adam.lazenby I can't get radio buttons to form properly with my theme. I need to have the label have a certain class and for the radio group to be contained inside a div with another class
# May 26th 2021, 21:52 ndm I'm just not sure if there's still a question pending :upside_down_face:
# May 26th 2021, 21:51 kevin.pfeifer someone is curious about the resolution :)
# May 26th 2021, 21:50 ndm Soooo... what issue did you find?
# May 26th 2021, 21:42 etibor where i can not attach to the query
# May 26th 2021, 21:42 etibor the real issue is by the index page
# May 26th 2021, 21:42 etibor its not a big deal when i need to do it in a view page, i simple make a pre query, and depends on the result make the second
# May 26th 2021, 21:41 etibor okey i may see the issue
# May 26th 2021, 21:37 etibor moment i am going to look for the sql query
# May 26th 2021, 21:37 kevin.pfeifer like ndm said, checking the generated SQL is the first easy thing you can do to see what cakephp does with your connections Otherwise trying to first come up with the pure SQL also helps because we can then try to help you convert that to how that query should be written in cakephp
# May 26th 2021, 21:35 ndm I mean... you can never have both for one review record then, because `class` can only be one of the two values. Is that what you expect? The default join type should be `LEFT`, but if you end up with an `INNER`, you'd never receive anything. So I'd again point to inspecting the queries.
# May 26th 2021, 21:35 etibor when the db field 'class' is internal (in Reviews) its means Clerks
# May 26th 2021, 21:34 etibor when the db field class is external(in Reviews) its means Secreters
# May 26th 2021, 21:33 etibor thank you @kevin.pfeifer your hint
# May 26th 2021, 21:32 etibor its a polymorphic association and point to 2 different models(Secreters and Clerks)
# May 26th 2021, 21:31 ndm So, a polymorphic self-association?
# May 26th 2021, 21:30 etibor thank you @ndm i am not sure, because it was from the ReviewsTable.php file
# May 26th 2021, 21:28 ndm In any case, use debug kit to inspect the generated queries, that might give some clue.
# May 26th 2021, 21:26 ndm Shouldn't the class name for both associations be `Reviews`?
# May 26th 2021, 21:26 etibor probably i have to add a matching but not sure
# May 26th 2021, 21:24 etibor but this is not a complete solution, i dont want to make 2 queries for this
# May 26th 2021, 21:24 etibor when i try to $this->Reviews->find('all')->contain(['Clerks','Secreters']) it does not return the Clerks or the Secreters However separetly its working well $this->Reviews->find('all')->contain(['Clerks']) or $this->Reviews->find('all')->contain(['Secreters'])
# May 26th 2021, 21:22 kevin.pfeifer just FYI: use three ` to create a multiline code block
# May 26th 2021, 21:21 etibor `$this->belongsTo('Clerks', [` 'className'=>'Clerks', 'foreignKey' => 'clerk_id', //'joinType' => 'LEFT', 'conditions'=>['Reviews.class'=>'internal'] ]); $this->belongsTo('Secreters', [ 'className'=>'Secreters', //'joinType' => 'LEFT', 'foreignKey' => 'secr_id', 'conditions'=>['Reviews.class'=>'external'] ]);
# May 26th 2021, 21:20 etibor well i almost implemented the whole, i added the 'class' and 'foreign_key' fields into the db table the issue is came when i tried to contain booth Models THe Model looks like this
# May 26th 2021, 21:18 etibor hello Kevin
# May 26th 2021, 21:17 kevin.pfeifer so you need table inheritance or what?
# May 26th 2021, 21:07 etibor is anyone who have ever worked with polymorphic associations
# May 26th 2021, 21:07 etibor hello everyone
# May 26th 2021, 16:11 erwane Sorry but i miss something about this plugin logic :(
# May 26th 2021, 16:10 hanchenglin101 Hello, everyone! I am looking for a CakePHP3 developer. Location: ANY, Welcome: Vietnam Period: 3 week ~ 5 weeks Hourly: 20 Please DM
# May 26th 2021, 14:32 tomrwaller Perfect - thank you. Nabbed an example from another baked view that I hadn't updated and the postLink works just fine. I think I changed it when trying to turn it into a button :face_with_rolling_eyes:
# May 26th 2021, 14:30 greg138 Yep. And the link you're generating is a GET link. So, either change it to a POST (which baking the view would do), or allow GET in your `allowMethod` call.
# May 26th 2021, 14:26 tomrwaller `$this->request->allowMethod(['post', 'delete']);`
# May 26th 2021, 14:25 tomrwaller Ah well this was baked so it's likely not been changed. I'll check.
# May 26th 2021, 14:21 greg138 Does your `delete` method allow `GET`, or just `POST`? I think the baked versions use post links for deletions.
# May 26th 2021, 14:19 tomrwaller Is anyone able to tell me why this doesn't work: `<?= $this->Html->link("<i class='fas fa-fw fa-trash'></i>", ['action' => 'delete', $assessment->id], array('class' => 'btn btn-sm btn-primary', 'escape' => false, 'confirm' => __('Are you sure you want to delete # {0}?', $assessment->id))) ?>` When I press the button on the assessments index page, I get the confirmation which I accept and I get
# May 26th 2021, 14:19 slackebot a 'Method not allowed' error: `return true;`             `}`         `}`         `$allowed = strtoupper(implode(', ', $methods));`         `$e = new MethodNotAllowedException();`         `$e->setHeader('Allow', $allowed);`         `throw $e;`     `}`
# May 26th 2021, 14:15 greg138 If the only thing your controller's `beforeFilter` function does is calls the parent version, then you may as well not have it at all; the parent version will just be used directly in that case.
# May 26th 2021, 13:48 erwane We can't define 'Model/Endpoint' directory ? I have multiple API Datasource and it's a little bit confusing to put everything in same folder
# May 26th 2021, 12:32 michal_kotus Hi, I am learning to work with mailer. I created `src/Mailer/UserMailer.php` with: ```namespace App\Mailer; use Cake\Mailer\Mailer; class UserMailer extends Mailer``` Why I can not put `$mailer = new Mailer();` inside? I get 10 errors immediately. What is wrong?
# May 26th 2021, 12:08 erwane README sounds good.
# May 26th 2021, 12:06 admad There aren't any docs so you'll have to see the existing implementations for reference :)
# May 26th 2021, 12:05 erwane will try with typesense
# May 26th 2021, 12:04 erwane Very nice, thanks
# May 26th 2021, 12:02 admad @erwane https://github.com/usemuffin/webservice
# May 26th 2021, 11:55 erwane maybe it's hard to do something "generic"
# May 26th 2021, 11:53 erwane Hi, there is no Core "Http Api" Datasource ?
# May 26th 2021, 11:11 neon1024 Is there an easier way to ensure all redirects are https? Or do I have to add `'_ssl' => true` to all my url arrays? Is that what the HttpsEnforcerMiddleware is for?
# May 26th 2021, 10:38 tomrwaller Awesome! Thanks - that does the trick! Quick question - It works using the 'templateVars' array key just fine - My only thought is it makes the code look a little untidy - is there a way to combine this into my helper template so I can get away with just using the 'help' keyword?
# May 26th 2021, 10:29 kevin.pfeifer you need to set custom template variables inside the `templateVars` array key when outputting the form See https://book.cakephp.org/3/en/views/helpers/form.html#adding-additional-template-variables-to-templates
# May 26th 2021, 10:26 tomrwaller Thought this might help: ```echo $this->Form->input('field_name', array( 'after'=>'<span class="help-block">This text appears underneath the input.</span></div>'));``` But it produces: ```<input class="form-control" type="text" name="name" after="<span class=andquot;help-blockandquot;>This text appears underneath the input.</span></div>"```
# May 26th 2021, 10:03 tomrwaller The help text is what I'm trying to get to display.
# May 26th 2021, 10:01 tomrwaller Ignore the 'help' entry - I was just playing with it. :)
# May 26th 2021, 10:01 tomrwaller `<?php`      `return [`         `'checkboxFormGroup'   => '<div class="form-check"><div class="checkbox">{{label}}</div></div>',`         `'checkbox'            => '<input type="checkbox" class="form-check-input" name="{{name}}" value="{{value}}" {{attrs}}>',`         `'checkboxWrapper'     => '<div class="form-check">{{label}} {{input}}</div>',`        
# May 26th 2021, 10:01 slackebot `'help' => '<small{{attrs}}>{{content}}</small>',`         `'inputContainer'      => '<div class="form-group">{{content}}</div>',`         `'input'               => '<input class="form-control" type="{{type}}" name="{{name}}" {{attrs}} />',`         `'label'               => '<label {{attrs}} class="control-label">{{text}}</label>',`         `'select'  
# May 26th 2021, 10:01 slackebot            => '<select class="form-control" {{attrs}} name={{name}}>{{content}}<select>',`         `'selectMultiple'      => '<div class="form-group"><select class="form-control" multiple="multiple" {{attrs}} name={{name}}[]>{{content}}</select></div>',`         `'error'               => '<p class="text-danger">{{content}}</p>',`         `'textarea'          
# May 26th 2021, 10:01 slackebot  => '<div class="form-group"><textarea class="form-control" name="{{name}}" {{attrs}}>{{value}}</textarea></div>',`         `'button'              => '<div class="form-group"><div><button class="btn btn-primary" {{attrs}} type="submit">{{text}}</button></div></div>',`         `'inputContainerError' => '<div class="form-group has-error" {{required}}>{{content}}</div>{{error}}',`     `];`
# May 26th 2021, 10:01 slackebot `?>`
# May 26th 2021, 10:01 tomrwaller All I'm trying to achieve is presenting a help text underneath my form controls. I think the helper I am using is causing the examples I've tried not to work.
# May 26th 2021, 09:49 dereuromark Adminlte etc are the most famous
# May 26th 2021, 09:48 dereuromark What's the problem? There are tons of open source ones out there if u google :)
# May 26th 2021, 09:33 tomrwaller I did :)
# May 26th 2021, 09:02 dereuromark Did u check the awesome list? ;)
# May 26th 2021, 08:49 tomrwaller Bonus points if it's Bootstrap 5 :) But at this point I'd take anything!
# May 26th 2021, 08:48 tomrwaller Hey everyone - I don't suppose anyone has a Bootstrap-enabled FormHelper template they wouldn't mind sharing with me at all? I've been using one over the years that I cobbled together through bits and pieces online but I'm noticing it doesn't provide me any scope to add input help-block text on my forms and I can't for the life of me figure it out.
# May 25th 2021, 23:23 ljolley Yea this gets the job done and how I've done it in the past.
# May 25th 2021, 23:21 ndm Depends on what exactly you mean by "_better_", that's very likely coupled to your specific application logic.
# May 25th 2021, 23:17 ljolley (I appreciate the help btw - I've been banging my head against this for too long today)
# May 25th 2021, 23:17 ljolley can you see a better way of handling this? Basically I have a set of logic that I need to run on every action with simple comparison checks - and if they fail, I redirect to where the user should be.
# May 25th 2021, 23:15 ndm Basically, yes.
# May 25th 2021, 23:15 ljolley got it. I modified my controller `beforeFilter` to have this: `return parent::beforeFilter($event);` and it appears to be doing what I need it to do. Is that what you meant by "overwritten method makes no use of it"?
# May 25th 2021, 23:12 ndm Alternatively, if applicable, you could also set the return value of `$this->redirect()` as the event result.
# May 25th 2021, 23:11 ndm Your return value from the parent method will vanish into the void, as your overwritten method makes no use of it. You need to check if `parent::beforeFilter()` returns something, and then return that in your overwritten method.
# May 25th 2021, 23:10 ljolley so controller action errors, and redirect doesn't happen.
# May 25th 2021, 23:09 ljolley but the controller action is looking for `$session->read('Admin.organization_id')`
# May 25th 2021, 23:09 ljolley again. redirect happens if I clear out the controller action
# May 25th 2021, 23:08 ljolley is that correct?
# May 25th 2021, 23:08 ljolley the code above is sitting in the `beforeFilter` in the `AppController`. It's literally the only thing in there ATM. In the controller, I have this: ```public function beforeFilter(EventInterface $event) { parent::beforeFilter($event); }```
# May 25th 2021, 23:06 ndm Either your `beforeFilter()` is not being invoked (maybe you've overwritten it incorrectly), or the conditions are not being fulfilled, ie the redirect is not being invoked.
# May 25th 2021, 22:54 ljolley Looks like if I put the same check in the controller action, it works. but it's much more efficient and easier to maintain if I can have it just run in the `beforeFilter`
# May 25th 2021, 22:45 ljolley regardless, I don't need the controller action to run.
# May 25th 2021, 22:43 ljolley not sure why. on actions that would fall under the same criteria, the redirect works - but there's no showstoppers in the controller action
# May 25th 2021, 22:43 ljolley this runs in the beforeFilter but it executes the controller action before the redirect happens
# May 25th 2021, 22:41 ljolley right.
# May 25th 2021, 22:38 greg138 `beforeFilter` does run before your controller's action starts.
# May 25th 2021, 22:34 ljolley looks like the `return` isn't returning?
# May 25th 2021, 22:32 ljolley working through this some more, it looks like the redirect is triggered, but the page errors out in the controller because it's expecting `$session->read('Admin.organization_id');` Is there a way to force the redirect in the `beforeFilter` before it hits controller logic?
# May 25th 2021, 22:25 ljolley top redirect under `//REDIRECT TO ORGANIZATION DASHBOARD` works fine.
# May 25th 2021, 22:25 ljolley ``` //CHECK THAT A CONTROLLER AND ACTION IS ACCESSIBLE DEPENDING ON IF THE USER IS LOADED INTO AN ORGANIZATION if($session->check('Admin.organization_id')) { //IF LOADED $access = $this->Access->actionCheck($this->request->getParam('controller'),$this->request->getParam('action'),'in'); if($access == false) { //REDIRECT TO ORGANIZATION DASHBOARD
# May 25th 2021, 22:25 slackebot $this->Flash->admin_info(__('Not an in action.')); return $this->redirect(['controller'=>'Dashboard','action'=>'organization','prefix'=>'Admin']); } } else if(!$session->check('Admin.organization_id')) { //IF UNLOADED $access = $this->Access->actionCheck($this->request->getParam('controller'),$this->request->getParam('action'),'out'); if($access
# May 25th 2021, 22:25 slackebot == false) { //REDIRECT TO MAIN DASHBOARD $this->Flash->admin_info(__('Not an out action.')); return $this->redirect(['controller'=>'Dashboard','action'=>'main','prefix'=>'Admin']); } }```
# May 25th 2021, 22:24 ljolley I have a check happening in the `AppController` `beforeFilter` and for whatever reason, the redirect doesn't trigger.
# May 25th 2021, 22:23 ljolley is there anything that would cause a redirect `$this->redirect()` to not work?
# May 25th 2021, 22:10 jojomartius sounds good @ndm thanks!
# May 25th 2021, 22:09 ndm @jojomartius That's controlled by the route class. Check your routes config for `setRouteClass()` or `routeClass()` calls, they might be missing, leaving you with the default route class that maps the path as-is. https://github.com/cakephp/app/blob/4.2.2/config/routes.php#L27-L45
# May 25th 2021, 21:46 jojomartius Does anybody has an idea what happend and how i can get the lower case routing also working?
# May 25th 2021, 21:44 jojomartius Hey there, i've a really stupid question. I created a plugin in an existing project with ```bin/cake bake plugin alert``` and a controller with ```bin/cake bake controller companies --plugin alert``` but if I try to access it via the browser on /alert/companies i got nothing, only on /alert/Companies (with a capital C) wir works...