⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to Create Fake Fields (a.k.a. Confirm Password) in Enterprise Edition



larasmith
  • profile picture
  • Member

Posted 05 June 2017 - 01:27 AM

In the community edition it is allowed to create fake fields which is used in confirm password forms.

How can I implement it in the enterprise edition? Please refer to the console in the photo below for the error.

I tried adding a field in the table named the same as the confirm password field and the error is gone.

I believe there is a better solution for this. I just can't figure it out yet.

 

 

image.png

 


larasmith
  • profile picture
  • Member

Posted 08 June 2017 - 23:30 PM

Any ideas in this one? Thanks!


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 10 June 2017 - 20:56 PM

Hello @larasmith,

 

In Grocery CRUD community, you are allowed to have faked fields, however you can't use it for search, ordering... e.t.c.

 

In Grocery CRUD Enterprise on the other side, you can use custom Queries in order to achieve that. So that simply means that you have a more powerful tool to use. You will need to use custom models for that. More specifically you will need to use the setModel (instructions at the link) and you will use your own query by extending the getList() with your own needs.

 

More specifically as you are using Codegniter, you can do something like that:

    public function getList() {

        $order_by = $this->orderBy;
        $sorting = $this->sorting;

        // Your own custom query with a specific select!

        if ($order_by !== null) {
            $this->db->order_by($order_by. " " . $sorting);
        }

        if (!empty($this->_filters)) {
            foreach ($this->_filters as $filter_name => $filter_value) {
                $this->db->like($filter_name, $filter_value);
            }
        }

        if (!empty($this->_filters_or)) {
            foreach ($this->_filters_or as $filter_name => $filter_value) {
                $this->db->or_like($filter_name, $filter_value);
            }
        }

        $this->db->limit($this->limit, ($this->limit * ($this->page - 1)));
        $results = $this->db->get($this->tableName)->result_array();

        return $results;

    }

I also have the code at gist if someone wants a full example of a codeigniter specific model: https://gist.github.com/scoumbourdis/2b75b1910b343ea00ce1fb310fffe02c

 

Hope that it helped

 

Thanks

Johnny