-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
Hello This is very strange, because I have no problems and the error message will also make no sense. I have installed it on a new install of PW without problems. The problem is the type hinting in this case: The method add() expects an object and the variable $gender in your case is an object - it is an object of the class Select. So there should not be a problem, but you can try the following: // Replace this code in FrontendForms/FormeElements/Form.php line 203 public function add(object $field) // with this code public function add($field) But before removing the type hinting from this method, please try the following: For testing purposes remove the add() method by the select field and take a look if the problem persists with other fields (fe. the name input field). Which version of PHP do you use? Please let me know!
-
Hello, as introduced in PW 3.0.181 modules can be shipped with translation files. I am trying to hook after the save method of this new functionality, but I could not get it to work. This hook is inside a module: // initialize the hooks public function init() { $this->addHookAfter('ProcessLanguage::save', $this, 'testHook'); } protected function testHook(HookEvent $event) { wire('session')->message('test'); } Nothing happens! Does anyone has an idea how to hook this new functionality. I have also tried it with fe ProcessLanguage::executeDownload but without success. Here is the Github page of the new feature: https://github.com/processwire/processwire/blob/master/wire/modules/LanguageSupport/ProcessLanguage.module
-
Hello @sp1ke thank you for your issue report. This error was produced by my editor during find and replace process. It is not possible to use $this inside the module info method. I have replaced all translateable strings from __('My string') to $this->_('My string') because using $this is the prefered method inside the class of a module. During these replacements I have overlooked the replacement inside the module info method. I have replaced it on GitHub to: 'summary' => __('Create forms and validate them using the Valitron library.'), So in this case the string is also translateable. Thanks
-
I found out that it happens if I use save() method without a parameter that was not set before. If I use for example save('title') and I set the title first, it works. // Works $p->title = 'My title'; $p->save('title'); // Does not work if title was not set before $p->save('title'); // Unfortunately this does not work $p->addStautus(Page::statusUnpublished); $p->save('status'); // and this does no work too $p->addStautus(Page::statusUnpublished); $p->save(); Any hints how to save the status?
-
Hello @ all I am struggeling with a saving problem of pages and could not find the reason. Description: I am using the following Hook inside a module: public function ready() { $this->addHookAfter('Modules::saveConfig', $this, 'setPageStatus'); } This Hook runs after the module was saved and triggers the the following setPageStatus method : /** * Sets the status of pages using the fl_register or fl_activation template to unpublished or published depending on the value of the * input_selectloginregister inputfield * @param HookEvent $e */ protected function setPageStatus(HookEvent $e) { $pages = wire('pages')->find('template=fl_register|fl_activation', ['findAll' => true]); foreach($pages as $p){ $p->setOutputFormatting(false); if($e->arguments(1)['input_selectloginregister'] == 'login'){ $p->addStatus('unpublished'); } else { $p->removeStatus('unpublished'); } $p->save(); $p->setOutputFormatting(true); } } I have found out that $p->save() method is responsible for the hight execution time and the error, but I do not know why. Everytime I remove this method the problem is gone. but of course the status will not be saved. Just to mention: There are always only 2 pages that will be saved - not more!!! Does anyone has an idea why the saving of the pages can exceed the execution time or a way to find out where the problem could be. Thanks in advance
-
Hello @ all I want to share a new module with you, which makes the creation and validation of forms easy. Take a look at the following example of a simple contact form: // A very simple example of a contactform for demonstration purposes $form = new Form('contactform'); $gender = new Select('gender'); $gender->setLabel('Gender'); $gender->addOption('Mister', '0'); $gender->addOption('Miss', '1'); $form->add($gender); $surname = new InputText('surname'); $surname->setLabel('Surname'); $surname->setRule('required'); $form->add($surname); $name = new InputText('name'); $name->setLabel('Name'); $name->setRule('required'); $form->add($name); $email = new InputText('email'); $email->setLabel('E-Mail'); $email->setRule('required'); $form->add($email); $subject = new InputText('subject'); $subject->setLabel('Subject'); $subject->setRule('required'); $form->add($subject); $message = new Textarea('message'); $message->setLabel('Message'); $message->setRule('required'); $form->add($message); $privacy = new InputCheckbox('privacy'); $privacy->setLabel('I accept the privacy policy'); $privacy->setRule('required')->setCustomMessage('You have to accept our privacy policy'); $form->add($privacy); $button = new Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if($form->isValid()){ print_r($form->getValues()); // do what you want } // render the form echo $form->render(); This piece of code creates a simple contact form and validates it according to the validation rules set. Inside the isValid() method you can run your code (fe sending an email) Highlights: 30+ validation types Support for UiKit 3 and Bootstrap 5 CSS framework SPAM protection Highly customizable Hookable methods for further customization Multi-language You can download and find really extensive information on how to use at https://github.com/juergenweb/FrontendForms. Please report errors or suggestions directly in GitHub. Best regards and happy testing ? If you have downloaded the module in the past I recommend you to uninstall the module completely and install the newest version 2.1.14. There are a lot of changes in the new version, so please test carefully.
- 296 replies
-
- 26
-
Hello @all I want to know if someone stumbled over the same problem: You have created a modul and during the installation process one or more fields will be created via the API. You have decided to use translateable strings for the field label, description etc. so it could be overwritten by translateable files. $field = new Field(); $field->type = $this->modules->get("FieldtypeDatetime"); $field->name = 'mydate'; $field->label = __('My Date'); So far so good. You install the module and everthing works fine. The label of the via API created FieldtypeDatetime is "My date". Now you want to overwrite this and therefore you create the translation file and overwrite it with fe "Your date". But then: Taking a look at the label of this inputfield on the edit form shows that the label has not changed. The reason for this behavior is, that the field was created before the translation file and therefore the overwritten label will not be used. So you have to go to the field configuration itself and change the label there or you uninstall the module and install it once more. In this case the translation file exists if it was created before and can be used during the creation process of the inputfields. It would be better if the overwritten value will be taken into account. It is not really a problem, but does anybody also struggle with this and found a way to solve this behavior. If not it does not matter. Best regards
-
Ok, doesn't work! I used this code inside my checking method to set and save config data: $data = wire('modules')->getConfig('MyModuleName'); if(Condition){ $data['permanent'] = true; } else { $data['permanent'] = false; } wire('modules')->saveConfig('MyModuleName', $data); The permanent value will be changed and saved inside the data table, but it seems that there is a module cache problem which prevents the uninstall checkbox from beeing updated (disabled or not).
-
Hello @all I am struggeling to find a way to set the checkbox status of the uninstall checkbox at the bottom of the module configuration page to disabled. I have created a module and I want that the checkbox should be disabled under certain conditions. I have tried to use this hook in my module file init method: $this->addHookBefore('ProcessModule::executeEdit', $this, 'showHideUninstallCheckbox'); and the method itself: protected function showHideUninstallCheckbox(HookEvent $event) { if(condition) .... run code to disable the checkbox } Maybe this hook is not suitable for this purpose. Can someone help me out to show me a way to achive this. Thanks in advance!!
-
Ok, I got it: Updating my Fieldtype file with this method solved my problem. I found this method inside the FieltypeText.module file. /** * Update a query to match the text with a fulltext index * * @param PageFinderDatabaseQuerySelect $query * @param string $table * @param string $subfield * @param string $operator * @param int|string $value * @return DatabaseQuerySelect * */ public function getMatchQuery($query, $table, $subfield, $operator, $value) { $ft = new DatabaseQuerySelectFulltext($query); $ft->match($table, $subfield, $operator, $value); return $query; }
-
Hello at all, I have created a new fieldtype with multiple fields (database columns) in it. More precisely it holds various company data (fe. company name, street, phone,...) - each in 1 database column. I want to make these values searchable in the site search, but it always shows me that the selector '~=' is not implement. It accepts '=' as a selector but not '~='. How can I implement this specific selector inside a fieldtype, so it does not throw me an error all the times, if I run a query with this selector. Thank you PS: My fieldtype class extends from Fieldtype
-
Thanks @LostKobrakai, but this was a misunderstanding. I wanted to prevent the usage of getUnformatted or page->of(false) or something like that method inside the template. I was looking for a possiblitiy to disable outputformatting inside the method itself, so I can use the API without adding a getUnformatted on the template base. But it doesnt matter, because it was a thinking mistake of mine. I dont need the unformatted value from the db - i need the value from the db in a specific format and therefore I am using a manipulation function to get the desired result. But it would be interesting if disabling the formatting inside a method itself is possible.
-
Hello @ all, Lets imagine I have a value stored in the database which I can output on the frontend with a simple API call like $page->myValue and this value will be manipulated with the formatValue() method before output on the frontend. So it was stored in the database like this: This is my value And after running through formatValue() method it will be: <p>This is my value.</p> So far so good. Now I have created a method inside my fieldtype/inputfield class which uses this value: public function myMethod() { $value = $this->myValue //value should be unformatted as dirctly stored in the database } Problem: myValue is always formatted because it runs through the formatValue method first - is there a way to get the "raw" data instead without setting ouputformatting to false inside the template if I call echo $page->myValue->myMethod(); I think it would not be possible because myMethod() is part of myValue, but maybe someone has an idea how it could work. Thanks in advance
-
2 new methods for Schema.org markup added: print_r($page->fieldname->getjsonLDTimes()); returns an array like this: Array ( [0] => Mo,Tu,We 08:00-12:00 [1] => Mo,Th 13:00-18:00 [2] => Th 08:00-11:00 ) Can be used to create the markup by yourself or echo $page->fieldname->renderjsonLDTimes(); returns a string like this: "Mo,Tu,We 08:00-12:00", "Mo,Th 13:00-18:00", "Th 08:00-11:00" You can use the second method in schema.org Local Business opening hours as followed: ..... "openingHours": [ "Mo,Th,Sa 11:00-14:30", "Mo,Th 17:00-21:30", "Fr,Sa 17:00-22:00" ], ..... Best regards
-
New feature added: I have updated the inputfield to support multilanguage timeformats on the frontend. You can set the timeformat of each language in the configuration of the inputfield in the backend (see screencast below). Supports strftime() and date() formats. Languageformat.mp4 Version was bumped from 1.0 to 1.1 on Github. Best regards Jürgen
-
Hello @ all I have 2 new methods added which take care of days with same times. It often happens that different days have exactly the same opening times. To prevent writing the same times over and over again, you can combine these days with this 2 new methods. 1) First new method to output a multidim. array print_r($page->fieldname->combinedDays()); You can use this array to create the markup by yourself. 2) Render method to output an unordered list of same opening times echo $page->fieldname->renderCombinedDays(); This method outputs a rendered string like this one: <ul class="uk-list"> <li>Mo, Fr: 08:00 - 16:00</li> <li>Tu, Th: 08:00 - 16:00, 18:00 - 20:00</li> <li>We: 16:00 - 23:05</li> <li>Sa, Su, Ho: closed</li> </ul> As you can see days with same times are combined now. Changes are added to Github now, so please download the files again if you want the latest version.? Best regards
-
Issue should be resolved and the file was updated on Github ?
-
Hi @bernhard Thanks for your feedback! I will check this and and try to find a solution. ? I have worked with this library in the past and it's really cool, but for the moment I have not planned to include a third party lib. The main purpose of this inputfield is to make entering of opening times simple for the user. Not really! Holidays are always hassle because they differ from country to country. For the moment you can enter only general opening times for all holidays. Exceptions can be really difficult and I guess there you will need to use Spatie to handle this.