Welcome Guest, Not a member yet? Register   Sign In
How to use is_unique?
#1

(This post was last modified: 04-18-2020, 09:14 AM by 5flex.)

I have a controller with code:
PHP Code:
...... other code .....
$props['login'] = 'test';
$props['mail'] = '[email protected]';

$this->validation->run($props'myrules');
...... 
other code ...... 

And now....In my app/Config/Validation.php I write next property:

PHP Code:
public $myrules = [
        
'login' => "is_unique[admins.login,id,{id}]",
        
'mail'  => 'is_unique[admins.mail,id,{id}]',
          



How I can transfer in THIS rule my VARIABLE WITH user ID??!!!

I want to GET the next code (as example):
PHP Code:
public $myrules = [
        
'login' => "is_unique[admins.login,id,314]",
                'mail'  => 'is_unique[admins.mail,id,314]',

    ];

// and next will GET query
// SELECT 1 FROM admins WHERE login = 'test' AND id != 314 


My QUESTION: "HOW TO SEND VARIABLE VALUE IN THE LAST ARGUMENT FROM MY CONTROLLER DINAMICALLY?"
Reply
#2

The placeholder should be replaced automatically by the value in the data array. See https://codeigniter4.github.io/userguide...aceholders
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(04-18-2020, 03:40 PM)includebeer Wrote: The placeholder should be replaced automatically by the value in the data array. See https://codeigniter4.github.io/userguide...aceholders

Have you carefully read my question?

Pay attention to my post! Did I ask somewhere about Models? I asked how to make validation from the controller, and not from Models.
Reply
#4

Hey, calm down. It's not with that kind of attitude that you'll get help here.

Since the Controller and Model both use the Validation library, I assumed they both work the same way. I looked at the code and it seems only the Model take care of the placeholders in the rules, with its fillPlaceholders() function.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

(04-19-2020, 04:47 AM)includebeer Wrote: Hey, calm down. It's not with that kind of attitude that you'll get help here.

Since the Controller and Model both use the Validation library, I assumed they both work the same way. I looked at the code and it seems only the Model take care of the placeholders in the rules, with its fillPlaceholders() function.


I'm from Russia and sorry for my bad English! I used Google Translate service to describe my problem and probably my text was strict.

I'm very sad at this version of Codeigniter. This is not release! It's maximum is BETA! I meet everyday so many bugs on each step in development process! In Views (I'm wrote in github)- bugs, In Models - bugs, In Libraries - bugs (as this) and so on.
Reply
#6

(This post was last modified: 04-19-2020, 06:18 AM by jreklund.)

Hi, I'm sad you feel that way about the software. But these are new found bugs that no one discovered in the release candidate face. As with all open source project, finding people to test the software are hard. Our user base for CodeIgniter 4 have increased significantly after the official release, because people actually start using everything.

That's why there are a lot of bugs to take care of at the moment. More people using it, in different ways. Leading to different "bugs" and solutions.

This particular bug have got a Pull request the other day, but haven't been merged in just yet.
https://github.com/codeigniter4/CodeIgniter4/pull/2819
Reply




Theme © iAndrew 2016 - Forum software by © MyBB