Jump to content

da²

Members
  • Posts

    387
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by da²

  1. OK, but the random bug is still there. Don't be in the urge to investigate this, I'll go for a classic HTML form because I have to finish this ASAP.
  2. enum TournamentType:string { case MYSTERY = "Mystery"; case PKO = "PKO"; case VANILLA = "Vanilla"; } class FilterSolvesForm extends AbstractFrontendForm { protected function buildForm(): void { $tournamentTypeSelect = new Select("tournamentType"); $tournamentTypeSelect->setLabel(__("Type de tournoi")); foreach (TournamentType::cases() as $tournamentType) { $tournamentTypeSelect->addOption($tournamentType->value, $tournamentType->value); } $this->add($tournamentTypeSelect); } } abstract class AbstractFrontendForm extends Form { public function __construct(string $id) { parent::__construct($id); $this->buildForm(); $this->addSubmit(); } private function addSubmit():void { $button = new Button('submit'); $button->setAttribute('value', __("Valider")); $this->add($button); } abstract protected function buildForm(): void; } // TEMPLATE PHP FILE $command = new SelectSolvesDatabaseCommand(1, 10); $filtersForm = new FilterSolvesForm("solvesFilterForm"); if ($filtersForm->isValid()) { // DevUtils::prettyPrintObject($filtersForm->getValue('tournamentType')); // $command->addFilter('tournamentType', $filtersForm->getValue('tournamentType')); } $filtersForm->showForm(true); $command->execute(); $solves = $command->getPaginatedSolves(); Twig::render('browse-solves', [ 'paginatedSolves' => $solves, 'filtersForm' => $filtersForm, ] );
  3. It's a simple Select: I tried again and find this is a random bug, sometimes it works, sometimes not. I made a video, we don't see the dropdown because I recorded only Firefox window, but I can confirm the list is always rendered in the same order as the top line "Mystery,PKO,Vanilla,", that is the order used to fill the Select element, so this is not a problem caused by a random order when initializing the form.
  4. I found in your code that it is $form->setAttribute('method', 'get'); (documentation needs an update 🙂 ). But now the page is empty after submission, empty head and body. I don't understand what's happening. EDIT: Looks like there is an exit() somewhere, because no code in my template is executed after $form->isValid() when I use GET method. 🧐
  5. Thank you @Juergen I edited my message with more questions while you were answering: Another thing, after form submission I'd like the form to be still displayed for another use, it is used to filter data in a table so it should always be visible. Actually after submission the form is hidden and replaced with the message "Thank you for your message.". I tried to use $form->showForm(true); but there is a bug, the value shown in the form is not always the value I selected before to submit (in a Select element). And another question, following the documentation I added $form->setMethod('get'); but get an error: "::setMethod does not exist or is not callable in this context"
  6. Hello, Is there a way to put some fields into a div, so I can manage form layout more precisely? Is it with the FieldsetOpen/FieldsetClose elements? EDIT: Another thing, after form submission I'd like the form to be still displayed for another use, it is used to filter data in a table so it should always be visible. Actually after submission the form is hidden and replaced with the message "Thank you for your message.". I tried to use $form->showForm(true); but there is a bug, the value shown in the form is not always the value I selected before to submit (in a Select element).
  7. This gives a warning, better like this: if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0) { Will you publish a fix?
  8. This gives the same error. I fill this is related with the module because this is not the first time I bootstrap PW and never had an issue before to install this module. You are using REQUEST_URI, but when bootstrapping, isn't it expected that it's not defined? It's easy to test, just include PW index.php in any script and run it directly (no web page involved).
  9. Another question/issue. I'm starting a new project, it will include bootstrapping code. I made a simple test, and I get an error from FrontendForms, error comes from the include of index.php. The test script: <?php namespace ProcessWire; include __DIR__ . "/../vendor/autoload.php"; include __DIR__ . "/../index.php"; The error: Is it a bug or do I have to do anything to avoid this?
  10. Hi, I'm testing your module, thanks for sharing it. 🙂 I'm creating a form to upload a zip file to a temporary directory (wire()->files->tempDir(uniqid())), then I need to open the zip and parse its content, the files will be deleted by PW at the end of the request. There's something I don't understand about file uploading, the file name on server disk is modified so it no longer uses the name given by the form, and it seems it's not using the PW filenames rules. For example: the file name on my disk is "testésim.zip". the form, when using $this->getValue('zipFile') returns "testésim.zip" (the same). but the file on server disk was renamed to "testesim.zip" (no more accent). and the PW sanitizer, wire()->sanitizer->filename($this->getValue('zipFile')), returns "testsim.zip" (totally remove the letter with accent). It looks like FrontendForms is renaming the file with its own rules, and not updating the InputFile field value to reflect the correct name. So what is the way to get the correct file name from FrontendForms? Actually, since the upload is limited to one file, I do a loop on upload directory to find it.
  11. Are you observing abnormal RAM usage before the crash? For the past few months, we've been experiencing an issue on a server that hosts several websites. MariaDB has been using more and more memory, and after a few weeks, it reaches the server's limit of 8 GB, causing the Linux kernel to kill processes. This issue started around the same time I installed a new site built with ProcessWire, but I can't say for sure that it's related. We've checked our MariaDB settings, the opened connections status, investigated what we could, but we haven't found the cause yet.
  12. What is disturbing me the most is the fact that I'm not finding pages (using Pages API) that are not enabled for the current user language. For example, I have a few templates that are not meant to be translated, so I disabled multi-language management ("Settings tab" in the template). But if user is not using the default language I don't find them. pages()->find('template=foo'); // Need all pages even if not enabled for current user language In Page Names module option, we can avoid the page to show a 404 and make it render in default language, but it's missing the same option using API to find pages (find(), children()...). I see 2 workarounds, not really satisfying: Always enable all languages on every page and template, even if they are not meant to be translated. Set user language to default before every kind of page search. This is too much, and error prone. A global option would be better. Maybe I'm missing another option?
  13. Just to add to this topic, Page class has a function to enable language, a bit cleaner than using "status$lang": foreach (languages()->findNonDefault() as $language) { $page->setLanguageStatus($language, true); }
  14. Thanks, I find this behavior a bit odd and think the option implemented in RockMigrations could be on the core module "Page Names". Creating pages via API doesn't use the same behavior as when using the admin interface, or even when generating pages within an admin hook (all languages are activated by default in these cases). I don't understand why this is different in a hook and when bootstrapping PW. Also, when we add a new language, every existing page is automatically enabled for this language, so why not doing it by default when a new page is created on front-end? Do you know the reasons behind these choices?
  15. Hello, My site (PW 3.0.240), using multi-language URLs since a few months, has default language french, and another language english. I don't know why, but a specific template is not accessible to english on front-end: If I go to the english URL of one of these pages, I get a 404. If I go to one of this pages in french, the language switcher shows only french as available language. If I display the pages of this template while using english, I get an empty list. I found that I checked in "template > advanced" the option "Disable multi-language support for this template" but: Enabling it again doesn't solve the issue. This option doesn't show a 404, it just switch language to default when loading this page. That was a mistake to check it, but not the cause of this issue (apparently). While writing this post, I investigated more and found the following. I finally found what makes these pages unreachable in english, this in the pages themselves, this checkbox is disabled in Settings tab: These pages are created dynamically, why is this "active" checkbox disabled, is it expected, and how to enable it automatically? This is more serious than it looks, because it ends with important bugs in the site and database inconsistencies. The problematic template represents a team in a competition. When a user using english language registers to a championship and creates a team, it is well created, BUT when he leaves the championship the team is not deleted because the find() method is not returning it, and the user is still referenced in the team even if not in this championship anymore. I'm disabling english to avoid more damages until I can fix this properly. How can I fix this? And if you have informations about this behavior, please explain or give documentation links, I'm a bit lost actually.
  16. Create 2 dates, one on the first day of the month, one on the last day, and use the selector "event_date>=begin, event_date<end". You are potentially loading thousands of pages here.
  17. Check that the root directory configured in your web server is the same than previous. The path before that has no importance. And obviously, don't use absolute paths in your code, but that shouldn't be the case. Also maybe check if your less compiler has an option to delete its cache, or a cache directory that is set to an absolute path maybe?...
  18. languages() global function is another way to get the instance, but wire()->languages property should work too.
  19. Hello, You can use $this->languages, wire()->languages or wire('languages'). I prefer to use wire()->languages so PhpStorm knows what I'm using.
  20. If trying to migrate an existing site from one server to another, the easiest is to copy files and replicate the database. No need to use the PW installer. Then, if wanted, you can update PW to the last version using the official module ProcessWireUpgrade.
  21. Both codes are NOT giving the same selector, you could check by printing it. First case gives: "item_number= " (with a space) Second one gives: "item_number=' '" (space inside quotes) To find empty values, you can just use "item_number=''" (no space inside quotes), or "item_number=" (nothing after equal). But I don't know why the first one is returning a page with item_number=50032. If you're sure everything is right on your side, maybe report a bug on Github.
  22. Hello, Are you using Apache? Is it configured to read .htaccess files? Is mod_rewrite enabled? https://gcore.com/learning/how-enable-apache-mod-rewrite/
  23. Hi, https://caniuse.com/?search=mp4
  24. I won't help for reading a function name. 😆 I don't know the module, check the documentation.
×
×
  • Create New...