# |
Apr 29th 2021, 17:33 |
tyler.adam.lazenby |
ooof its a png |
# |
Apr 29th 2021, 17:32 |
tyler.adam.lazenby |
```$this->enableCsrfToken(); $this->post('/accounts/add', $data); $this->assertResponseOk();``` |
# |
Apr 29th 2021, 17:32 |
tyler.adam.lazenby |
and finally the test |
# |
Apr 29th 2021, 17:32 |
tyler.adam.lazenby |
```$data = [ 'user' => $user, 'name' => $name, 'phone_number' => $phone_number, 'Addresses' => $Addresses, 'is_billing_same_as_mailing' => "1", 'logo' => $this->testFile, ];``` |
# |
Apr 29th 2021, 17:32 |
tyler.adam.lazenby |
and here is the data being loaded into an array |
# |
Apr 29th 2021, 17:32 |
tyler.adam.lazenby |
here is my file being created in the test ```$this->testFile = new UploadedFile( $testFilePath, filesize($testFilePath), \UPLOAD_ERR_OK, 'logo.png', 'image/jpeg' );``` |
# |
Apr 29th 2021, 17:31 |
slackebot |
null given, called in C:\xampp\htdocs\ezBusinessManager\src\Controller\AccountsController.php on line 81 in C:\xampp\htdocs\ezBusinessManager\src\Controller\Component\AWSComponent.php on line 124``` |
# |
Apr 29th 2021, 17:31 |
tyler.adam.lazenby |
Hey there, I am trying to test with post that includes a file upload. I am on the controller test right now, and I have made the file itself a new Laminas/Uploaded file instance. The issue is that when I try to test it via post, it says that the file index is null. ```Error: [TypeError] App\Controller\Component\AWSComponent::createFile(): Argument #1 ($file) must be of type Psr\Http\Message\UploadedFileInterface, |
# |
Apr 29th 2021, 16:35 |
rightscoreanalysis |
seems it doesn't return the most relevant results |
# |
Apr 29th 2021, 16:35 |
rightscoreanalysis |
if you search the book for 'Components' a bunch of results come back but not https://book.cakephp.org/4/en/controllers/components.html |
# |
Apr 29th 2021, 12:11 |
etibor |
I tried to point out from the current layout path by this: $this->viewBuilder()->setLayoutPath('./Administrator/layout'); but it does not help it still stay in the same |
# |
Apr 29th 2021, 11:34 |
etibor |
i added this to the routes.php: $routes->connect('administrator/support', ['prefix'=>false,'controller' => 'Contacts', 'action' => 'support']); $this->request->prefix does not show the address in the url in my case, if i could get the real prefix(which is in the url bar) i could set the right menu layout |
# |
Apr 29th 2021, 11:03 |
slackebot |
by get the prefix but it does not works, its show false it does not matter in the route I would not like to repeat the layouts in the non prefixed layout Do you have any hint? |
# |
Apr 29th 2021, 11:03 |
etibor |
i stuggle with an issue, i use prefixed controllers, however i have non prefixed controllers for commonly used functions i use layouts for the menus(each prefix has different layouts) the issue is that when i try to use the common functions its display its default layout i tried to add a new route which contain the prefix and points to the common function(non-prefixed) and tried to set the layout in the commonly used function |
# |
Apr 29th 2021, 10:57 |
etibor |
thank you @st.steinkuehler you are great |
# |
Apr 29th 2021, 09:04 |
steinkel |
`$this->getController()->viewBuilder()` |
# |
Apr 29th 2021, 09:03 |
steinkel |
@etibor navigate to the Controller from inside the Component first, then you'll be able to get the viewBuilder() |
# |
Apr 29th 2021, 07:55 |
etibor |
i use a component for functions used common by different controllers for example i have a user profile function in the component, where i try to change the layout(the menu) like this: $this->viewBuilder()->setLayout($this->request->prefix); but o got: Call to undefined method App\Controller\Component\CommonFunctionsComponent::viewBuilder() how can i use the viewbuilder in a Component? |
# |
Apr 29th 2021, 07:52 |
etibor |
Hello all |
# |
Apr 28th 2021, 18:57 |
rightscoreanalysis |
does anyone know of a Twitter API plugin for recent version of Cake? |
# |
Apr 28th 2021, 15:33 |
greg138 |
If it works sometimes, then the configuration is fine. |
# |
Apr 28th 2021, 14:14 |
admad |
@erwane there's `DateTimeTimezoneType` https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeTimezoneType.php. So you can use that for your fields and contact the timezone to your POSTed values in `beforeMarshal()` |
# |
Apr 28th 2021, 13:26 |
admad |
Don't have time to look into it now, you can open an issue if you think it's something that can be improved in the core. |
# |
Apr 28th 2021, 13:24 |
erwane |
@admad what do you think about my problem ? |
# |
Apr 28th 2021, 12:41 |
slackebot |
?I18nDateTimeInterface { /** @psalm-var class-string<\Cake\I18n\I18nDateTimeInterface> $class */ $class = $this->_className; return $class::parseDateTime($value, $this->_localeMarshalFormat); } ``` Time-zone is not passed to `parseDateTime` and set to UTC by default. Maybe need to add a `localeTimezone` parameter ?``` |
# |
Apr 28th 2021, 12:41 |
slackebot |
->useLocaleParser(true) ``` When patching entity with this data, it's passed to `Marshaller` then `DateTimeType` and it build a FrozenTime object with wrong time-zone : ```php object(Cake\I18n\FrozenTime) id:0 { 'time' => '2021-04-21 08:00:00.000000+00:00' 'timezone' => 'UTC' ``` The problem is in the method `\Cake\Database\Type\DateTimeType::_parseLocalValue()` ```php protected function _parseLocaleValue(string $value): |
# |
Apr 28th 2021, 12:41 |
erwane |
```My website has form with a date-time picker, localized to user language/locale. Time-zone is set globally to `UTC` and date-time are displayed in the correct user time-zone. The field display : `04/21/2021 08:00` for users in West-Coast or `21/04/2021 08:00` in France. In Controller::initialize() i set something like that, for a french user ```php TypeFactory::build('datetime') ->setLocaleFormat('dd/MM/yyyy HH:mm') |
# |
Apr 28th 2021, 12:39 |
erwane |
i've prepared an issue about that but don't post because there is alternative but i can expose here |
# |
Apr 28th 2021, 12:37 |
erwane |
(alternative to my problem) ```if ($news->getError('published')) { $news->setError('published-datepicker', $news->getError('published')); } }``` |
# |
Apr 28th 2021, 12:37 |
admad |
what timezone issue you have with DateTimeType? In 4.x it allows you to specify the db timezone |
# |
Apr 28th 2021, 12:34 |
admad |
value of hidden field is what will be submitted and validated in php |
# |
Apr 28th 2021, 12:34 |
erwane |
I can't use "localized" datetime format due to a bug in DateTimeType (timezone is missing) I convert user choice in ISO string in an hidden field. |
# |
Apr 28th 2021, 12:30 |
erwane |
but ... flatpickr use an hidden field too, problem is same. Validation should be done on the value of hidden field |
# |
Apr 28th 2021, 12:28 |
erwane |
i don't like this answer :) but you certainly right |
# |
Apr 28th 2021, 12:19 |
kevin.pfeifer |
then you should use the right datetime picker library ;) I switched to https://flatpickr.js.org/examples/ and it works great |
# |
Apr 28th 2021, 12:15 |
erwane |
Is it possible, in cake4, to add validation on hidden field and report error to another "fake" field ? It's a datetime picker who set date in hidden field but i want error displayed under the picker field. |
# |
Apr 28th 2021, 12:11 |
erwane |
which cake2 version ? |
# |
Apr 28th 2021, 11:14 |
k4t |
only %25 is causing problems |
# |
Apr 28th 2021, 11:14 |
k4t |
Hello, in old CakePhP2 project we are facing issue in which when in the url is encoded percentage symbol, for example "/suche/%25" then we got Bad Request error from HTTP server. It does not happen in projects which use CakePHP3. Can someone help me? |
# |
Apr 28th 2021, 08:50 |
d.lisiecki93 |
so basically we have same settings, thanks @kevin.pfeifer for help, ill contact with Amazon then :) |
# |
Apr 28th 2021, 08:49 |
kevin.pfeifer |
nothing more |