Custom Attribute Types

Permalink
Hi all

I've run into some problems creating a new custom attribute type. I copied the folder from /concrete/attributes/boolean to /application/attributes/boolean2. I changed line 2 of the controller.php in boolean2 (the new custom attribute type) to read:

namespace Application\Attribute\Boolean2;


I've changed nothing else, I can see no other references to the CORE that should affect the class.

I then went into my CMS and went to system and settings->attributes (at dashboard/system/attributes/types). My new attribute shows up for installation but the icon link is broken. It's still pointing to concrete/attributes. When I install the new type a get an error:

ReflectionException (-1)
Class \Concrete\Attribute\Boolean2\Controller does not exist

I cannot work it out. The new attribute type is added to my database table attribute types but still not installing properly. I cannot access that system->attributes page again without an error until i delete that entry from the table.

Any ideas?

I'm using version 5.7.4/2

 
WillemAnchor replied on at Permalink Reply
WillemAnchor
I replicated the problem.
It tries to find the icon and the controller in \concrete instead of \application.

edit your application/bootstrap/app.php file and add:
Core::bind('\Concrete\Attribute\Boolean2\Controller', function($app, $params) {
      return new \Application\Attribute\Boolean2\Controller($params[0]);
   });


Another problem:
You will probably be missing the atBoolean2 table.
Create a db.xml file in your map:
<?xml version="1.0"?>
<schema version="0.3">
<table name="atBoolean2">
    <field name="avID" type="I" size="10"><KEY></KEY><DEFAULT value="0"></DEFAULT><UNSIGNED></UNSIGNED></field>
    <field name="value" type="I"><DEFAULT value="0"></DEFAULT></field>
  </table>
</schema>


I didn't get the icon right yet, but that prolly needs another line in app.php