-
Posts
160 -
Joined
-
Last visited
-
Days Won
2
Andy last won the day on April 30 2024
Andy had the most liked content!
Profile Information
-
Gender
Male
-
Location
Cyprus
Recent Profile Visitors
6,800 profile views
Andy's Achievements

Sr. Member (5/6)
137
Reputation
-
INQUEST digital archive - showcase for 40th anniversary
Andy replied to millipedia's topic in Showcase
Hi @millipedia You have turned out to have a great website. It's really necessary work, but it's also beautiful. -
Hi @Juergen Good news everybody. Custom validation rules work. I'll add one more proven validation rule to the general collection. Check to enter a Cyrillic first, last or middle name. In ready.php // // Cyrillic name may contain lowercase and uppercase а-я and hyphen // \Valitron\Validator::addRule('cyrillicName', function ($field, $value) { $regex = '/[^а-яё\-]/iu'; if (!preg_match($regex, $value)) { return true; } return false; },'contains not allowed characters. Cyrillic name may contain lowercase and uppercase а-я and hyphen (no whitespaces).');
-
Hi @Juergen I continue to admire you. Yes, that's exactly what I meant. That's what I was thinking about writing a new validation rule, just haven't decided how to do it yet. I was going to use hooks. You've shown a logical solution. Thank you. I think FrontendForms users can share their useful validation rules in this thread.
-
Hi @Juergen Thank you for your quick response. You are always helpful. This code now works and shows an error message at the beginning of the form. However, the problem is that despite the error, the variable $form->isValid() = true. And the form submittal happens. Is there any way to tell the form that it is invalid? And make $form->isValid() = false. That would solve all the problems with additional inspections.
-
Hi Juergen First of all, I didn't find the setErrorMessage function in your code. But you have the setErrorMsg function. Here's the code I used: if($form->isValid()) { $selector = $sanitizer->text($form->getValue('title'), $options = ['stripQuotes'=>true,'stripSpace'=>true]); $selector = preg_replace('/[^а-яё]/ui','', $selector); If(empty($selector)){ // set an error message at the top of the form $e_msg = "The name must be in Cyrillic."; $alert0 = $form->getAlert(); $alert0->setErrorMsg($e_msg); } } However, I get an error either way: Exception: Method Alert::setErrorMsg does not exist or is not callable in this context (in wire/core/Wire.php line 563) Perhaps there is some other way to change the value of $form->isValid() to false?
-
Hi @Juergen First of all, I didn't find the setErrorMessage function in your code. But you have the setErrorMsg function. Here's the code I used: if($form->isValid()) { $selector = $sanitizer->text($form->getValue('title'), $options = ['stripQuotes'=>true,'stripSpace'=>true]); $selector = preg_replace('/[^а-яё]/ui','', $selector); If(empty($selector)){ // set an error message at the top of the form $e_msg = "The name must be in Cyrillic."; $alert0 = $form->getAlert(); $alert0->setErrorMsg($e_msg); } } However, I get an error either way: Exception: Method Alert::setErrorMsg does not exist or is not callable in this context (in wire/core/Wire.php line 563) Perhaps there is some other way to change the value of $form->isValid() to false?
-
Impressive website. There's a lot to learn from you.
-
Hi @Juergen Unfortunately, the suggested example doesn't work 18 hours ago, Juergen said: 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'); } } First of all, I didn't find the setErrorMessage function in your code. But you have the setErrorMsg function. Here's the code I used: if($form->isValid()) { $selector = $sanitizer->text($form->getValue('title'), $options = ['stripQuotes'=>true,'stripSpace'=>true]); $selector = preg_replace('/[^а-яё]/ui','', $selector); If(empty($selector)){ // set an error message at the top of the form $e_msg = "The name must be in Cyrillic."; $alert0 = $form->getAlert(); $alert0->setErrorMsg($e_msg); } } However, I get an error either way: Exception: Method Alert::setErrorMsg does not exist or is not callable in this context (in wire/core/Wire.php line 563) Perhaps there is some other way to change the value of $form->isValid() to false?