-
Posts
157 -
Joined
-
Last visited
-
Days Won
2
Andy's Achievements

Sr. Member (5/6)
133
Reputation
-
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?
-
Hi @bernhard This project looks extremely interesting. I use Tabulator for frontend and find it one of the best solutions for tables. It's great that you have made it easier to use it in the backend. Thank you for another one great module. By the way, I have up to 50 columns in a table, and the database has over 1,000,000 items. However, it doesn't make much sense to make tables of even 10,000 rows. It is better to categorize them and show them in separate tables.