Logs for #cakephp

Page 35 of 36,922, showing 100 records out of 3,692,143 total, starting on record 3,401, ending on 3,500

# At Username Text
# Jun 11th 2021, 09:03 kevin.pfeifer in your JS code?
# Jun 11th 2021, 09:01 paolo.bragagni where I have to see?
# Jun 11th 2021, 09:01 paolo.bragagni my ajax call to controller is not fired
# Jun 11th 2021, 08:34 kevin.pfeifer ndm is currently in the process of updating the friendsofcake/boostrap-ui plugin to bootstrap 5 https://github.com/FriendsOfCake/bootstrap-ui/pull/350 Maybe you can find something usefull there
# Jun 11th 2021, 08:32 slackebot     `'buttonToolbar' => '<div class="btn-toolbar{{attrs.class}}"{{attrs}}>{{content}}</div>',`         `'fancyFileInput' => '{{fileInput}}<div class="input-group"><div class="input-group-btn">{{button}}</div>{{input}}</div>'`     `];` `?>`
# Jun 11th 2021, 08:32 slackebot class="form-group">{{submitContainerHorizontalStart}}{{content}}{{submitContainerHorizontalEnd}}</div>',`         `'submitContainerHorizontal' => '<div class="form-group"><div class="{{inputColumnOffsetClass}} {{inputColumnClass}}">{{content}}</div></div>',`         `'inputGroup' => '{{inputGroupStart}}{{input}}{{inputGroupEnd}}',`         `'inputGroupStart' => '<div class="input-group">{{prepend}}',`
# Jun 11th 2021, 08:32 slackebot        `'inputGroupEnd' => '{{append}}</div>',`         `'inputGroupAddons' => '<span class="input-group-addon">{{content}}</span>',`         `'inputGroupButtons' => '<span class="input-group-btn">{{content}}</span>',`         `'helpBlock' => '<p class="help-block">{{content}}</p>',`         `'buttonGroup' => '<div class="btn-group{{attrs.class}}"{{attrs}}>{{content}}</div>',`    
# Jun 11th 2021, 08:32 slackebot name="{{name}}[]" multiple="multiple" class="form-control{{attrs.class}}" {{attrs}}>{{content}}</select>',`         `'radio' => '<input type="radio" name="{{name}}" value="{{value}}"{{attrs}}>',`         `'radioWrapper' => '<div class="radio">{{label}}</div>',`         `'radioContainer' => '<div class="form-group">{{content}}</div>',`         `'inlineRadio' => '<input type="radio"
# Jun 11th 2021, 08:32 slackebot name="{{name}}" value="{{value}}"{{attrs}}>',`         `'inlineRadioWrapper' => '{{label}}',`         `'inlineRadioNestingLabel' => '{{hidden}}<label{{attrs}} class="radio-inline">{{input}}{{text}}</label>',`         `'textarea' => '<textarea name="{{name}}" class="form-control{{attrs.class}}" {{attrs}}>{{value}}</textarea>',`         `'submitContainer' => '<div
# Jun 11th 2021, 08:32 slackebot {{labelColumnClass}}{{attrs.class}}"{{attrs}}>{{text}}</label>',`         `'labelInline' => '<label class="sr-only{{attrs.class}}"{{attrs}}>{{text}}</label>',`         `'nestingLabel' => '{{hidden}}<label{{attrs}}>{{input}}{{text}}</label>',`         `'legend' => '<legend>{{text}}</legend>',`         `'option' => '<option value="{{value}}"{{attrs}}>{{text}}</option>',`        
# Jun 11th 2021, 08:32 slackebot `'optgroup' => '<optgroup label="{{label}}"{{attrs}}>{{content}}</optgroup>',`         `'select' => '<select name="{{name}}" class="form-control{{attrs.class}}" {{attrs}}>{{content}}</select>',`         `'selectColumn' => '<div class="col-md-{{columnSize}}"><select name="{{name}}" class="form-control{{attrs.class}}" {{attrs}}>{{content}}</select></div>',`         `'selectMultiple' => '<select
# Jun 11th 2021, 08:32 slackebot class="{{inputColumnClass}}">{{prepend}}{{input}}{{append}}</div>',`         `'hiddenBlock' => '<div style="display:none;">{{content}}</div>',`         `'input' => '<input type="{{type}}" name="{{name}}" class="form-control{{attrs.class}}" {{attrs}} />',`         `'inputSubmit' => '<input type="{{type}}"{{attrs}}>',`         `'inputContainer' => '<div class="form-group
# Jun 11th 2021, 08:32 slackebot {{type}}{{required}} mb-3">{{content}}</div>',`         `'inputContainerError' => '<div class="form-group has-error {{type}}{{required}}">{{content}}{{error}}</div>',`         `'label' => '<label {{attrs}} class="form-label text-primary" style="text-transform: uppercase">{{text}}</label>',`         `'labelHorizontal' => '<label class="control-label
# Jun 11th 2021, 08:32 tomrwaller Hey guys - in an attempt to avoid having to re-invent the wheel, I was wondering if anyone happened to have a Bootstrap 5 Form Helper template they are williing to share. The one I have is still Bootstrap 4 and things have changed a fair bit. Below is what I have already. Anyone able to share? Or even point me to one online? I've looked around quite a lot but had no joy so far. `<?php`      `return [`        
# Jun 11th 2021, 08:32 slackebot `'button' => '<button{{attrs}}>{{text}}</button>',`         `'checkbox' => '<input class="form-check-input" type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',`         `'checkboxFormGroup' => '<label for="{{text}}" class="form-label">{{text}}</label>',`         `'checkboxWrapper' => '<div class="form-check">{{label}}</div>',`         `'checkboxContainer' => '<div
# Jun 11th 2021, 08:32 slackebot class="mb-3">{{content}}</div>',`         `'checkboxContainerHorizontal' => '<div class="form-group"><div class="{{inputColumnOffsetClass}} {{inputColumnClass}}"><div class="checkbox {{required}}">{{content}}</div></div></div>',`         `'dateWidget' => '<div class="row">{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}</div>',`         `'error' => '<span class="help-block
# Jun 11th 2021, 08:32 slackebot        `'formStart' => '<form{{attrs}}>',`         `'formEnd' => '</form>',`         `'formGroup' => '{{label}}{{prepend}}{{input}}<span class="help form-text text-muted small"><i class="fas fa-fw fa-question-circle"></i>andnbsp{{help}}</span>{{append}}<!-- formGroup help -->',`         `'formGroupHorizontal' => '{{label}}<div
# Jun 11th 2021, 08:32 slackebot error-message">{{content}}</span>',`         `'errorHorizontal' => '<span class="help-block error-message {{errorColumnClass}}">{{content}}</span>',`         `'errorList' => '<ul>{{content}}</ul>',`         `'errorItem' => '<li>{{text}}</li>',`         `'file' => '<input type="file" name="{{name}}" {{attrs}}>',`         `'fieldset' => '<fieldset{{attrs}}>{{content}}</fieldset>',`
# Jun 11th 2021, 08:27 kevin.pfeifer definitely :)
# Jun 11th 2021, 08:27 paolo.bragagni :)
# Jun 11th 2021, 08:27 paolo.bragagni (I was near)
# Jun 11th 2021, 08:26 paolo.bragagni thanks
# Jun 11th 2021, 08:23 kevin.pfeifer ```$type = $this->Categories->getSchema()->getColumnType('id');```
# Jun 11th 2021, 08:19 paolo.bragagni in cake 2 I did this
# Jun 11th 2021, 08:19 paolo.bragagni $this->loadModel($model); $tipo_colonna = $this->$model->getColumnType($field);
# Jun 11th 2021, 08:19 paolo.bragagni in cake4 how to get the coloumn type of a filed?
# Jun 11th 2021, 08:17 ovidiu.marinoiu cool, thanks!
# Jun 11th 2021, 08:16 kevin.pfeifer @ovidiu.marinoiu you can get the “parent” Controller (from which you use the component) via `$controller = $this->getController();` Then you can access the model via that variable as if you were in the controller `$controller->MyModel->find()` But components are meant to be used by multiple controllers so you don’t always have the same controller
# Jun 11th 2021, 08:05 ovidiu.marinoiu Hi! how can I import a model, in cakephp4, in a component. Found that in previous versions it was possible using ClassRegistry.
# Jun 11th 2021, 05:17 paolo.bragagni (trying to make template with search function for index view)
# Jun 11th 2021, 05:16 paolo.bragagni I have to built call back function that tests if input is numeric, or there are other easy ways?
# Jun 11th 2021, 05:15 paolo.bragagni but if user enter string value I got an error
# Jun 11th 2021, 05:15 paolo.bragagni $this->searchManager() ->add('numero_scaffale', 'Search.Value', [ 'fields' => ['numero_scaffale'],
# Jun 10th 2021, 22:17 jpramirez Ah O.K. so this is not a unit test, because you are not testing your model domain, but the interaction with the outer world from your app's perspective. I am saying this only to remind you to write unit tests, and not only some let's call them end to end tests. When interacting with an API, your only chance is to mock the contract with your API. Does this make sense to you?
# Jun 10th 2021, 22:08 tyler.adam.lazenby The the refresh token you save to prevent you from doing that
# Jun 10th 2021, 22:08 tyler.adam.lazenby Its because Google OAuth only allows you to refresh a token 5 times within a given period of time
# Jun 10th 2021, 22:07 jpramirez Can you re-explain your question @tyler.adam.lazenby ? A unit test that works five time only is a cheap one :smiling_face_with_tear:
# Jun 10th 2021, 21:36 tyler.adam.lazenby Really complicated question here. I am testing with oAuth connections, and unit testing the token with my test database works 5 times until the max number of refresh tokens allowed for a client are met. How would you go about making sure that once a refresh token is saved, that the fixture itelf accepts that?
# Jun 10th 2021, 18:44 tyler.adam.lazenby I mean, I get it the route collection ensures have the collection ready to go
# Jun 10th 2021, 18:43 admad Smart :)
# Jun 10th 2021, 18:42 tyler.adam.lazenby that is what I got it from :P
# Jun 10th 2021, 18:42 admad That's essentially what's used to parse the current request url too :)
# Jun 10th 2021, 18:38 greg138 In 3.x, at least, it seems that `loadRoutes` is called by any router function that might need them, like `url`.
# Jun 10th 2021, 18:38 kevin.pfeifer thats cool, didn’t know that :thinking_face:
# Jun 10th 2021, 18:36 kevin.pfeifer routes are definitely not loaded by default
# Jun 10th 2021, 18:35 tyler.adam.lazenby ```public function sendEmail() { $this->Authorization->skipAuthorization(); $referrer = $this->request->referer(); $params = Router::getRouteCollection()->parse($referrer); return $this->response->withDisabledCache() ->withType('application/json') ->withStringBody(json_encode([ 'url' => $referrer, 'params' => $params ])); }```
# Jun 10th 2021, 18:34 kevin.pfeifer `Cake\TestSuite\TestCase` yes
# Jun 10th 2021, 18:34 tyler.adam.lazenby but I think I just figured out a way
# Jun 10th 2021, 18:34 tyler.adam.lazenby Just the refering url
# Jun 10th 2021, 18:33 greg138 I've never needed to do this. Are you extending Cake's `TestCase` class?
# Jun 10th 2021, 18:29 kevin.pfeifer if so then you have everything in this array ```$params = $this->getRequest()->getAttribute('params');```
# Jun 10th 2021, 18:28 kevin.pfeifer do you have a request object where you want to do that?
# Jun 10th 2021, 18:22 tyler.adam.lazenby I know you can reverse an array into a string, but I can't seem to figure out how to take the referer url and make it something my system can use
# Jun 10th 2021, 18:22 tyler.adam.lazenby Is there a method for taking apart a url and seperating it into its Router elements?
# Jun 10th 2021, 18:06 tyler.adam.lazenby yay! finally got it to spit out the referer
# Jun 10th 2021, 17:55 tyler.adam.lazenby thanks
# Jun 10th 2021, 17:55 tyler.adam.lazenby I was looking for something like that
# Jun 10th 2021, 17:53 kevin.pfeifer https://book.cakephp.org/4/en/development/testing.html#loading-routes-in-tests
# Jun 10th 2021, 17:53 kevin.pfeifer ```public function setUp(): void { parent::setUp(); $this->loadRoutes(); }```
# Jun 10th 2021, 17:53 kevin.pfeifer you need to load them in your setup function
# Jun 10th 2021, 17:53 kevin.pfeifer routes are not loaded automatically in tests
# Jun 10th 2021, 17:51 tyler.adam.lazenby ```public function testSendEmail(): void { $referral_url = Router::url([ 'controller' => 'Contacts', 'action' => 'view', 1 ], true); $headers = ['referrer' => $referral_url]; $this->configRequest([ 'headers' => $headers ]); $this->get('contact/send-email'); $data = json_decode($this->_getBodyAsString()); dd($data); }```
# Jun 10th 2021, 17:51 tyler.adam.lazenby Cake\Routing\Exception\MissingRouteException : A route matching "array ( 'controller' => 'Contacts', 'action' => 'view', 0 => 1, 'plugin' => NULL, '_ext' => NULL, )" could not be found.
# Jun 10th 2021, 17:51 tyler.adam.lazenby Well that is all well and good, until you have this error because phpunit doesn't build the router
# Jun 10th 2021, 17:48 kevin.pfeifer didn’t read slack before posting :,)
# Jun 10th 2021, 17:48 kevin.pfeifer well
# Jun 10th 2021, 17:48 kevin.pfeifer ``` $this->configRequest([ 'headers' => ['Accept' => 'application/json'] ]);```
# Jun 10th 2021, 17:45 tyler.adam.lazenby Oof thanks
# Jun 10th 2021, 17:45 greg138 https://book.cakephp.org/3/en/development/testing.html#setting-up-the-request
# Jun 10th 2021, 17:44 tyler.adam.lazenby Hetting the appropriate header with phpunit?
# Jun 10th 2021, 17:44 greg138 That's just a matter of setting the appropriate header in your simulated call to `send-email`.
# Jun 10th 2021, 17:44 tyler.adam.lazenby exactly
# Jun 10th 2021, 17:44 kevin.pfeifer so you check the url / referrer of that ajax call in your controller function?
# Jun 10th 2021, 17:42 tyler.adam.lazenby to `/contacts/send-email`
# Jun 10th 2021, 17:42 tyler.adam.lazenby I just want to simulate for example making a get request from /appname/contacts/view/1
# Jun 10th 2021, 17:41 greg138 Simulate which part of it? There's great support for testing controller actions with any method you want and any data you care to pass to them.
# Jun 10th 2021, 17:41 kevin.pfeifer now i understand
# Jun 10th 2021, 17:41 kevin.pfeifer ahhhhhh
# Jun 10th 2021, 17:41 tyler.adam.lazenby sorry just lots of issues and my adhd brain is developing code and asking at the same time
# Jun 10th 2021, 17:40 tyler.adam.lazenby problem is how do you simulate making the request from a page with unit testing?
# Jun 10th 2021, 17:40 greg138 If it's something that's going to be invariant, why wouldn't you use a unit test? It confirms your initial code, and also makes sure it keeps working forever.
# Jun 10th 2021, 17:39 kevin.pfeifer why should that be janky?
# Jun 10th 2021, 17:39 kevin.pfeifer ok then i totally dont get what youre asking :,)
# Jun 10th 2021, 17:39 tyler.adam.lazenby Just seems janky
# Jun 10th 2021, 17:38 tyler.adam.lazenby hahaha yeah yeah I know
# Jun 10th 2021, 17:38 kevin.pfeifer well you can set a xdebug breakpoint in a test as well if you want :)
# Jun 10th 2021, 17:38 tyler.adam.lazenby and I use PHPstorm so unit testing is very easy
# Jun 10th 2021, 17:37 tyler.adam.lazenby because I use a CI
# Jun 10th 2021, 17:37 tyler.adam.lazenby ok, I get that, but I also am unit testing lol
# Jun 10th 2021, 17:37 kevin.pfeifer in this case where you probably just return json data and want to check what is in a variable you can also just log the variable with `Log::write()`
# Jun 10th 2021, 17:35 tyler.adam.lazenby I personally make heavy use of `debug()` and `dd()`
# Jun 10th 2021, 17:34 tyler.adam.lazenby without having to pass that
# Jun 10th 2021, 17:34 tyler.adam.lazenby I am basically trying to make an ajax command that will check if the page making the request is contact action called view, and then check to see what the ID of the viewed item is
# Jun 10th 2021, 17:34 kevin.pfeifer but I know enough people who still prefer/löve `var_dump()` aka `pr()`
# Jun 10th 2021, 17:34 tyler.adam.lazenby hahaha
# Jun 10th 2021, 17:33 kevin.pfeifer I basically can't live without xdebug any more :)
# Jun 10th 2021, 17:33 tyler.adam.lazenby exactly, like if for example I am making sure I am getting the referrer's parsed parameters
# Jun 10th 2021, 17:28 kevin.pfeifer like when you are first creating the logic for that controller action?
# Jun 10th 2021, 17:26 tyler.adam.lazenby when you are first going through creating a controller action, and want to make sure you are getting the right information passed, do you use unit testing (as opposed to just echoing it to the screen) or is there a more "standard" approach?
# Jun 10th 2021, 13:52 philo.hamel see `colType`