<p>I found the solution of this was under my nose,</p>

<p>I added this </p>

<pre><code>public function populateElementModel($row){

  $model = Plugin_ClientModel::populateModel($row);
  return $model;

}
</code></pre>

<p>In <code>Plugin_ClientElementType</code> and then <code>getCpEditUrl()</code> it works.</p>

CC BY-SA 3.0
2015-06-08T14:42:12.733Z
2015-06-08T14:42:12.733Z
Alex
<p>I have a plugin. In this plugin I did elementtype which extends the user one, but with only one source "clients". I have and New Client button which points to my plugin <code>Plugin_ClientController</code> which looks like this:</p>

<pre><code>class Plugin_ClientController extends UsersController
{

    public function actionIndex( array $variables = array() ) {

       $this-&gt;renderTemplate('plugin/client/_index');

    }

    public function renderTemplate($path, array $variables = array()) {

        $path = str_replace('users/', 'plugin/client/', $path);
        parent::renderTemplate($path, $variables);

    }   

}
</code></pre>

<p>I don't know if this is the right way to do this, but it seems to work,
so like this I can have my one view for Client edit, which is almost the same as users one.</p>

<p>My elementtype is look like this:</p>

<pre><code>class Plugin_ClientElementType extends UserElementType
{

    public function getSources($context = null)
    {
        $sources = array(
            '*' =&gt; array(
                'label'    =&gt; Craft::t('Clients'),
                'criteria'  =&gt; array('groupId' =&gt; 1),
                'hasThumbs' =&gt; true
            )
        );
        return $sources;
    }

}
</code></pre>

<p>So all fine up to here. The problem is in that list:
<img src="https://i.sstatic.net/SUbB8.png" alt="enter image description here"></p>

<p>where I list all my clients the url on the title in my case now <code>User1</code> is pointing to <code>admin/users/[ID]</code>
I would like to change it to <code>plugin/client/[ID]</code> if that possible I know that it has to be in the model like this:</p>

<pre><code>class Pluign_ClientModel extends UserModel
{

    protected $elementType = 'Plugin_Client';


    public function getCpEditUrl()
    {
        return UrlHelper::getCpUrl('plugin/client/' . $this-&gt;id);
    }


}
</code></pre>

<p>But it seems that it's not coming from there. If someone can help me with this would be great. Thank you in advance.</p>

<plugin-development><admin><elementtype><extends>
Change title url of elementtype in the list
# Change title url of elementtype in the list

(Asked by: username_0 on 2015-06-04)

I have a plugin. In this plugin I did elementtype which extends the user one, but with only one source "clients". I have and New Client button which points to my plugin Plugin_ClientController which looks like this:
class Plugin_ClientController extends UsersController
{

    public function actionIndex( array $variables = array() ) {

       $this->renderTemplate('plugin/client/_index');

    }

    public function renderTemplate($path, array $variables = array()) {

        $path = str_replace('users/', 'plugin/client/', $path);
        parent::renderTemplate($path, $variables);

    }   

}

I don't know if this is the right way to do this, but it seems to work,
so like this I can have my one view for Client edit, which is almost the same as users one.
My elementtype is look like this:
class Plugin_ClientElementType extends UserElementType
{

    public function getSources($context = null)
    {
        $sources = array(
            '*' => array(
                'label'    => Craft::t('Clients'),
                'criteria'  => array('groupId' => 1),
                'hasThumbs' => true
            )
        );
        return $sources;
    }

}

So all fine up to here. The problem is in that list:

where I list all my clients the url on the title in my case now User1 is pointing to admin/users/[ID]
I would like to change it to plugin/client/[ID] if that possible I know that it has to be in the model like this:
class Pluign_ClientModel extends UserModel
{

    protected $elementType = 'Plugin_Client';


    public function getCpEditUrl()
    {
        return UrlHelper::getCpUrl('plugin/client/' . $this->id);
    }


}

But it seems that it's not coming from there. If someone can help me with this would be great. Thank you in advance.

**Tags:** plugin-development, admin, elementtype, extends


---

## 1 answers

### Answer by username_0 on 2015-06-08. Score: 3 | Accepted answer

I found the solution of this was under my nose,
I added this 
public function populateElementModel($row){

  $model = Plugin_ClientModel::populateModel($row);
  return $model;

}

In Plugin_ClientElementType and then getCpEditUrl() it works.


---

