Jump to content

Juergen

Members
  • Posts

    1,410
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Juergen

  1. The form will be always submitted after pressing the send button 😉 You have the choice, what should be done inside the isValid() function. This method returns always true if the "standard validation does not fail". It is up to you to make another validation inside the isValid() method, but there is no possibility to make isValid to false manually. As I explained in the example some post before, you can do addtional checks inside the isValid() method. Depending on the results of your custom checks you can send fe an email or not. The only problem could be that the form will not be displayed after isValid() is true. The code is not designed to handle such special cases, sorry!
  2. Try $alert0 = $form->getAlert(); $alert0->setText($e_msg); $alert0->setCSSClass('alert_dangerClass'); // or alert_successClass or alert_warningClass setErrorMsg() is a method of the form object
  3. I need to check the whole module files 🤪. After that I will bump up the version number, so you can download the latest version with the fixes.
  4. How can I miss that - I've always overlooked that! Thanks for the relevant information - this will save me a lot of time and troubles in the future.🙂
  5. Hello @PWaddict It seems that @Robin S has found the problem. Take a look here. I'll test it on mylocalhost and on the live site over the weekend and post my results here, but I'm sure this solves the problem.
  6. I have tried it and now it is working well on my localhost!!!! I will test it on a live site too, but it should work there too. Thank you!!!!!
  7. This could be the possible reason for the strange behavior. I will try it! Thank you so much!! 🙂
  8. I have no clue why this works under certain circumstances. I will take a look at the weekend. Otherwise I delete the hooking section if it does not work properly.
  9. You are right! It works on my localhost, but not on my live site. This is very strange!!!!
  10. It is a little bit difficult to explain: Direct call of a class method on a page: $form = new Form(); echo $form->render(); The method will be called directly on a page, so hooking Form::render works. Direct call of a method of another class inside a method on a page: public function ___render() { $out = ''; $object = new Element(); $out .= $object->renderElement(); return $out; } As you can see the method renderElement of the class Element will be called inside the render method of the Form class so Element::renderElement is hookable too. The problem occurs if a method of the Element class should be hooked that is not directly called inside the given renderElement() method. class Element { public function ___test() { return 'Test'; } public function ___renderElement{ return 'Element'; } } So if you want to hook Element::test it will not be triggered, because it will not executed inside the renderElement() method. That was my experience with the hook problem
  11. Could you please post the code of your init.php. I have taken the screenshots after adding this code to my init.php and as you can see it works in my case.
  12. Conclusion: It is not possible to hook a class that is not loaded directly on a page. In my case, the Label class is loaded and used indirectly within the form, as it is used within the inputfield class and not directly in the form class. The form class is loaded directly onto the page and can be hooked - the Label class is not.
  13. Hello @PWaddict I have adapted the hook to change the form markup inside the readme file to get it working now. The previous versions of hooks did not work, because the hooks will never be triggered. Instead you have to hook "Form::render" and change the markup there. Here you can see the example of the readme file to change the markup of the asterisk on required fields. Before: After: Hope this helps
  14. Hello @Frank Vèssia I have taken a look at this issue and I will not change the "untitled-xxxx" to something else, because this username is absolutely unique. If you want to prevent, such random usernames to be stored inside the database, then please go to the module configuration and go to the tab for the registration form. There please add the field "Username" to the registration form (and to the profile form as well if you want). This forces the user to enter a username during the registration process and you will not get the randomly created "untitled-xxxx". Best regards
  15. Hello @Frank Vèssia The untitled-xxxxx as name will be added by default if you choose login with email and password and not with username and password. BTW the random username can be overwritten by the user itself if he wants. So there is no need for the user to accept this random username. I know this is not a really nice random username, but using the email address instead is not a good idea, because if you want to output the username on the frontend, everyone can see the email address. I guess the "untitled" will be added by PW if nothing is entered in the name field and the number will be appended by a hook as I can remember, but I have to take a look (I do not remember exactly). The untitled-xxxx will be added by PW and makes the name absolutely unique. I will think over if there will be simple solution to change the name to a more nicer one 😉
  16. Hello @Andy Take a look at the custom rules. There are some ready-to-use validators which check against the database (fe. uniqueEmail to check if email is not registered inside the user table). List of Custom rules If you want to check against custom tables, you have to check it inside the isValid() method by your own. There is no possibility to create and add custom rules by yourself. if ($form->isValid()) { //make your custom check here (fe checking a form value against the database) if(customcheck is valid){ // go on with your code } else { // set an error message at the top of the form $alert = $form->getAlert(); $alert->setErrorMessage('Sorry, but there are errors inside the form'); // set an error message on the inputfield itself (fe. an email input) $emailInput = $form->getFormElementByName('email); $emailInput->setErrorMessage('There is an error'); } } I have not tested the code above, but you got the idea such an issue could be solved. The last option is to write an request on Github for a new validator and if it could be useful for others I will try to implement it 😉 Best regards
  17. Thanks for your quick response @bernhard I compared your example to mine and I see that you are calling the method ($foo->hello()) inside your ready() method. In this case it works on my side too, but this is not the scenario that I want. I want to manipulate the output not inside the ready() but before page render, so the markup of the method should be changed before the page will be rendered. public function ___renderAsterisk(): string { return '<span class="asterisk">*</span>'; } This is a render function, which will be called during the render function of the form and the form will be rendered during the page will be rendered. So I want to change the output of the renderAsterisk() method inside the site/init.php and this does not work at all. wire()->addHookAfter('Label::renderAsterisk', function ($event) { $event->return = ' - hooked aha :)'; }); So this works fine if the renderAsterisk() method will be called inside the ready.php separately. $foo = new Label(); bd($foo->renderAsterisk()); But it does not work if the renderAsterisk() method is included inside another render function (in this case inside the render function of the form. This should be the issue of the problem. To simplify: It works if the renderAsterisk() method will be called directly, but not if this method is included within another method and will be called there.
  18. Hello @bernhard This is interesting, but in my case the hook does not get fired. It seems that that it will be ignored. The function is hookable by prefixing 3 underscores: public function ___renderAsterisk(): string { return '<span class="asterisk">*</span>'; } The class 'Label' itself (where the function above is part of) is derived from the Wire class (take a look here on the top parent class), so hooks must be implemented and should work. Only to mention: the top parent class called 'Tag' is an abstract class - could this have an impact on the issue? Do you have a working example in one of your numerous modules, where you use a hook inside the init.php to hook a method in one of your modules?
  19. Hello @PWaddict I guess this is a namespace related problem, but I have not found a solution to this issue. Therefore I have written a blog post in the forum in the hope others could help. Best regards
  20. Hello @all I have tried to apply a hook to a class of a module of my mine which runs inside a namespace. The hook is included inside the site/init.php. $this->wire()->addHookAfter('Label::renderAsterisk', function(HookEvent $event) { bd('render Asterisk'); }); This hook runs on the function renderAsterisk() which is hookable and part of the class "Label" (original File: Label.php). This class descends from Wire so hooks should work inside this class, but I guess the main problem is that this class runs inside its own namespace called "FrontendForms". So I tried different versions within the hook to define the class: FrontendForms\Label::renderAsterisk \FrontendForms\Label::renderAsterisk \\FrontendForms\Label::renderAsterisk FrontendForms\\Label::renderAsterisk None of the versions above work! After a search on the internet, I found a discussion about this problem here. It seems that other people have also stumbled upon this problem. My question: Has anyone already struggled with the same problem and found a solution on how to get hooks to work on classes with namespaces, or could there be another cause responsible for this behavior? Additional info: This issue comes from my FrontendForms module and I've used hooks in the past to manipulate the output a bit (look here). The hooks have worked in the past, but it seems that they don't work anymore in PW version 3. Thanks for your help!
  21. Hello @PWaddict I can remember that someone has posted the same problem in the past. I will take a look at this issue tomorrow, but as I can remember the Hook problem was a PW problem and not a FrontendForms problem. Please be patient! I will try to trace the problem to its source Best regards
  22. Hello @MarkE Thank you for reporting this issue on sites with many pages (and providing a solution). My websites don't have many pages, so I've never encountered such an issue. 😉 I've integrated your fix into the latest version (1.3.15), so the issue should be fixed by now. According to your suggestion to make the "move" of a child page optional, I will take a look at it in the near future. Thanks Jürgen
  23. FrontendLoginRegister module is updated now (Version 1.3.6) The following last 2 issues have been fixed now: Support for usage of multilanguage fields inside user template added New configuration field to make the "Request deletion of user account page" public viewable added Screenshot of the new configuration field to change the access of the user account deletion page: In the middle you can see the "Allow public deletion of a user account" checkbox. If you check this checkbox, the deletion page will be public reachable. For more information check the changelog.md. Please keep in mind! This module is Beta stage, so it is not recommended to update live sites without testing it locally before! I have tested various scenarious, but I cannot test all possible cases - so happy testing 😉 As always, please report any issues here or on GitHub.
  24. The following issues should be solved now: The position of the privacy check is now always at the bottom, regardless of the use of a CAPTCHA (bug fixed) New configuration field to select whether to use an internal or external page for the privacy policy added. This configuration supports multilingualism, which means you can select a different page for each language. These issues have been fixed in the FrontenForms module and not in the FrontendLoginRegister module. This means that you will need to update the FrontendForms module to the latest version 2.2.27 to fix these issues. The other problems (public deletion link, multilanguage user fields) directly affect the FrontendLoginRegister module and must be solved there. I will try to solve these issues in the next time. You can read the full documentation of changes in the changelog.md. Hope it works now as expected without problems!!
  25. I will add an additional configuration field in the backend, where you can select if you want to use an internal page or enter the link to an external page for linking to the privacy page.
×
×
  • Create New...