# |
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 |
slackebot |
`?>` |
# |
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 |
=> '<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 |
`'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 |
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 |
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. |