1

I want add custom types to Ng-admin. I didn't find complete info or sample to do it. As a sample, I want add next types: embedded object, embedded_list type, parted combo box and others.

My confuse is what syntax and structure of TypeField and TypeFieldView files.

1 Answers1

2

You custom type should extend the Field type at least, or another existing type.

// in path/to/MyCustomDateField.js
// ES6 version
import DateField from 'admin-config/lib/Field/DateField';
export default class MyCustomDateField extends DateField {
    formatSmall() {
        return this.format('small');
    }
}

// ES5 version
var DateField = require('admin-config/lib/Field/DateField');
function MyCustomDateField(name) {
    DateField.call(this, name);
}
MyCustomDateField.prototype = new DateField();
MyCustomDateField.prototype.formatSmall = function() {
    return this.format('small');
}
module.exports = MyCustomDateField;

As a side note, please don't post your question to too many places (e.g. here, in the ng-admin gitter, and in the ng-admin bugtracker). This gives us more work to provide support.

François Zaninotto
  • 7,068
  • 2
  • 35
  • 56
  • Hi François. I need to create a custom type also but these directions aren't enough as I don't really know how the code is structured. I need to know where to code this. Your help would be more than welcomed. I created and updated an issue on github : https://github.com/marmelab/ng-admin/issues/622 – Armel Larcier Aug 28 '15 at 09:08
  • 1
    The documentation for custom types has been updated and is now much easier to follow. See https://github.com/marmelab/ng-admin/blob/master/doc/Custom-types.md – François Zaninotto Sep 02 '15 at 08:37