All Activity
- Today
-
szabesz started following Prompt Manager
-
https://github.com/clipmagic/ProcessPromptManager @psy Thanx for sharing!
-
Good morning @da² I have wrapped my head around your problem and I have found a possibility to check file uploads against the value of an input field by using a custom validation. In the following example you have 2 form fields: Field 1 is a text input where you have to enter the name of a file (for example "myfile") without the extension Field 2 is the file upload field where you upload a ZIP folder with different files. Validation check In this simple example it will be checked if there is a file with the filename entered in field1 present inside the files uploaded in field 2. In other words: Check if the uploaded ZIP folder contains a file with the filename for example "myfile" in this case. If yes, then the form submission is successful, otherwise an error will be shown at field 1. This is only a simple scenario to demonstrate how a custom validation could be done. You have to write your own validation rules. Now lets write some code for this example: The first one is the custom validation rule. Please add this code to your site/init.php. If this file does not exist, please create it first. <?php namespace ProcessWire; \Valitron\Validator::addRule('checkFilenameInZip', function ($field, $value, array $params) { $fieldName = $params[0]; // fieldname of the upload field $form = $params[1]; // grab the form object // get all the files from the given ZIP folder as an array $zipfiles = $form->getUploadedZipFilesForValidation($fieldName); // now start a validation rule with the value of this input field ($value) and the files inside the ZIP folder if (!is_null($zipfiles)) { $fileNames = []; foreach ($zipfiles as $zipfile) { $fileNames[] = pathinfo($zipfile, PATHINFO_FILENAME); } return in_array($value, $fileNames); } return true; }, 'must be a wrong filename. The ZIP folder does not contain a file with the given name.'); I have named the validation rule "checkFilenameInZip" in this case. The important thing is that you have to add 2 values to the $params variable: The name of the file upload field The form object itself To get all the files that were uploaded via the upload field, you can use one of these methods of the form object. getUploadedZipFilesForValidation (outputs only files of a ZIP file) getUploadedFilesForValidation (outputs all files of a file upload field) Important: To use these 2 new methods you have to update to the latest version of FrontendForms (2.3.14)! All ZIP files will be extracted automatically. Nested ZIP files are supported too. Now lets create the form $form = new \FrontendForms\Form('testform'); $form->setMaxAttempts(0); // set 0 for DEV $form->setMaxTime(0); // set 0 for DEV $form->setMinTime(0); // set 0 for DEV $form->useAjax(false); // set false for DEV // input field containing a filename $filename = new \FrontendForms\InputText('filename'); $filename->setLabel('Name of file'); $filename->setNotes('Please enter the name of the file without extension.'); $filename->setRule('required'); $filename->setRule('checkFilenameInZip', 'fileupload1', $form);// here is the new custom validation rule: Enter the name of the file upload field as the first parameter and the form object as the second parameter $form->add($filename); // the file upload field $file1 = new \FrontendForms\InputFile('fileupload1'); $file1->setRule('required'); $file1->setLabel('Multiple files upload'); $form->add($file1); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if ($form->isValid()) { // do what you want // $extractedFiles = $form->getUploadedFiles(true); // returns all uploaded files including extracted ZIP folder files // $nonExtractedFiles = $form->getUploadedFiles(); // returns all uploaded files but Zip files are not extracted // $values = $form->getValues(); // returns all submitted form values } echo $form->render(); Copy this code and paste it inside a template for testing purposes. Upload a ZIP folder and add the name of a file inside the "filename" input field. If the file exists in your ZIP folder you will succeed. Please note: The extraction of the ZIP files is done only once during the validation process. You can get the extracted files afterwards inside the isValid() method via the getUploadedFiles() method from the temporary upload folder. Use the return of this method to do some more work with the uploaded files. Take this example as a starting point for your own validation rules and let me know if it works for you. I think this is the only possibility to get what you need. Another hint: User browser validation in FrontendForms to make client side validation first by enabling it in the backend.
- Yesterday
-
psy started following Prompt Manager
-
ProcessPromptManager is a ProcessWire admin module for building site-aware prompt definition exports for external AI agents. It lets an administrator choose a ProcessWire template, select the fields an agent is expected to provide, add human-written instructions, and export a zip containing a markdown prompt plus small JSON files that describe the expected field payload.
- 1 reply
-
- 4
-
-
Hello @da² Thank you for your detailed explanation! Now I know what your goal is. The first problem by doing additional validations inside the "isValid()" method after all form values are valid is that the form has "status valid" and therefore the form values will be emptied to prevent double form submission. That is the reason why the form is empty. This can be prevented by adding the useDoubleFormSubmissionCheck() method with value false to the form object. The second problem is that the validation of max attempts (if enabled) will be reseted if the form is valid, but it would take further attempts if you are doing additional validations inside the isValid() method. So the max attempts validation in this case does not work. But this can be disabled by using the setMaxAttempts() method and setting the value to 0. So adding additional validations inside the isValid() method is a very dirty solution and the module is not developed to support such a scenario. So the goal you want to achive is very difficult to achive. I am afraid that the module will not be able to solve your problem, but I will wrap my head around it and maybe I have an idea.🤔
-
I loved this theme - very similar to the new one, but somehow better. I actually prefer Bernhard's stock UIKit theme to the new one, not sure exactly why. I wish Canvas was the default theme.
- 48 replies
-
- 1
-
-
robert changed their profile photo
-
50 Templates + 14 Repeaters 🙂
-
I'll see if I have time to do a full case study. The map is easily explained though: Since Switzerland is a very small country, stretching it onto a 2D plane can be done without much distortion. That's where the LV03 and LV95 coordinate systems come into play. They are centered at the observatorium of the ExWi building of the University of Bern (where I studied CS :P). From there, you count the meters to the north and the east (and add some offsets so there are no negative coordinates). Using Switzerland's official map service, you can easily come up with LV95 coordinates for any address. These are then added to the locations in the PW admin. The map thus is just an SVG and placing the dots is just simple LV95 coordinate to pixels interpolation. No external services needed, no privacy concerns.
-
1) 75 (+15 Repeaters) 2) 62 (+4) 3) 50 (+7)
-
Shocking stuff. Perhaps a good title would be Another great reason not to use WordPress. 🙂 In PW world, how many of us run Module updates through any audit before installing?
- 1 reply
-
- 2
-
-
https://anchor.host/someone-bought-30-wordpress-plugins-and-planted-a-backdoor-in-all-of-them/ Without any ill intent, this comes across to me as sounding like promotion for ProcessWire.
- 1 reply
-
- 2
-
- Last week
-
You can try to compare the Textarea field settings. I have seen this behaviour when the editor setting uses a faulty js / css file path. Maybe a custom JSON file have been moved.
-
P.s. a Textarea field in the SEO section is on the other hand working properly.
-
howdytom started following Textarea disappearts after 1 sec
-
It could also caused by PHP version upgrade from your hosting provider or faulty TinyMCE / CKEditor JS settings. Do you have access to your server logfiles? Which PW version do you use? Which default editor has been set for the text field. TinyMCE or CKEditor? Did you try to re-save the textarea field settings?
-
Hi Sabesz, I already tried that; both a different browser and icognito, it doesnt matter. The strange thing is, I see the Textbox litterally disappearing for my eyes, so I think it is something in Processwire, maybe a security or setting issue? Michael
-
szabesz started following Textarea disappearts after 1 sec
-
Hi, it might be a browser extension causing this. Do you have any extensions installed? If so, you can try a different browser or an incognito/private window, provided extensions are not allowed to run in that mode.
-
MichaelNL started following Textarea disappearts after 1 sec
-
Hi, As my developer has stopped with servising my Processwire site, I am asking for help here. In the admin area, it seems that pages with a "textarea" field dont show their content after 1 second. Even if I refresh the whole page, I can see the original input in the textarea, but it disappears after 1 second. It is not possible to edit the textarea... It looks like a system setting has been changed? The last time I used the site (2 months ago) everything was still working fine.
-
Sergio started following PageMarkdown — Export any page to Markdown
-
Very useful, indeed! May I suggest an example in its docs for the developer to implement: - A URL segment `/md/` or, even better, adding `.md` to the URL to trigger the display of the markdown version of the page?
-
😂 https://www.tomshardware.com/tech-industry/artificial-intelligence/claude-code-deletes-developers-production-setup-including-its-database-and-snapshots-2-5-years-of-records-were-nuked-in-an-instant EDIT, the post-mortem by the developer: https://alexeyondata.substack.com/p/how-i-dropped-our-production-database
-
Hi, thanks for the explanation. I'll try to explain my actual case, it's more complex and would be easier to manage if I could just invalidate a form field manually. The form has a zip field, zip file contains several files. To make the explanation short, I extract the zip and validate its content, but the validation also requires to know values from the other fields in the form. I think this is the first problem: accessing the other fields (only if they are validated by the form) while validating the zip field. So I have a field "A", form should valid it (basic validation, like "required"), then while validating zip content (another field) and extracting its data I check again field "A" against the zip data. If there's an issue I must invalidate field "A" (but I'm processing zip field) and display an error on this "A" field. In one sentence: I know that field "A" is wrong only when processing zip field. Also this validator seems to make things more complex. I don't want to extract/validate the zip 2 times, once in validator, and once again when form is fully validated (isValid() function) to save values in database. So I should refactor code to store the validated data somewhere to reuse them in isValid() function, this is extra complicated work I want to avoid. Also this is not a light process for CPU, zip can be 500 MB and contain a lot of files to parse (some are also zip to extract again), this is a heavy process and I don't like the idea of doing this 2 times. Telling the form "this field is not valid and should display this error message" is way more simple and doesn't necessitate extra code, I just have to return an error code from the high level class that process data and invalidate one or another field. If you have an idea to avoid processing zip 2 times and without adding extra work, it would be welcomed, hope my explanations are clear (I'm not sure 😆). Actually I'm displaying error message on form result page, and in case of error the user has to fill again the whole form. My client is OK with this since this form is mainly used by himself, but I'm not happy because this is also a public form that a user could use, and having the whole form reset in case of error is a bad design. This is the actual code in template php: $form = new UploadSolveForm(); if ($form->isValid()) { $uploadFilePath = $form->getSolveFilePath(); $tagsText = trim($form->getValue('tagsFinalInput')); $tags = $tagsText ? explode(',', $tagsText) : []; $parseCommand = new ParseSolveUploadCommand( $uploadFilePath, trim($form->getValue('groupName')), $tags, RoomType::from($form->getValue('room')), boolval($form->getValue('isSpaceKo')), $form->getValue('subtreeVilainPosition') ? TablePosition::from($form->getValue('subtreeVilainPosition')) : null, $form->getValue('subtreeVilainAction') ? PlayerAction::from($form->getValue('subtreeVilainAction')) : null, $form->getValue('subtreeHeroPosition') ? TablePosition::from($form->getValue('subtreeHeroPosition')) : null ); if (!$parseCommand->execute()) { // I would like to do: // $errorCode = $parseCommand->getErrorCode(); // if ($errorCode == ParseSolveUploadCommand::SOME_ERROR){ // $form->setError('a field name', 'errorMessage'); // } else if($errorCode == ParseSolveUploadCommand::SOME_OTHER_ERROR){ // $form->setError('another field name', 'errorMessage'); // } if ($parseCommand->getUserErrorMessage()) NoticeManager::add($parseCommand->getUserErrorMessage(), NoticeType::ERROR); // Will display an alert box on form result page else NoticeManager::add(__("Une erreur s'est produite, merci de contacter un administrateur.", COMMON_TRANSLATION_DOMAIN), NoticeType::ERROR); } else { $parseCommand->getReport()->noticeUser(); } } Thank you for your interest. 🙂
-
Top one is 62 (+23 repeaters). Regular ones are 15 to 25.
-
I presume, then, if you know it's not animated and you want the webp version you can use ->webp. It's probably good as it is in hindsight.
-
Exactly. That's the reason. 🙂
-
1) 147 2) 60 3) 46
-
maximus changed their profile photo