mesx
mesx

Reputation: 1165

ExtJS 4.1: Override mixins

I got a small question: ExtJS 4.1 uses a mixin called "Ext.form.Labelable" for all form fields to render labels. I would like to change the labelableRenderTpl, which is the rendering template, for all form fields to add an extra label to the right side. How can i override/exend a mixin? Is it even possible or do i have to override the labelableRenderTpl for all classes who uses the mixin?

Thx for your help and best regards! Manuel

Upvotes: 4

Views: 3316

Answers (1)

sra
sra

Reputation: 23983

You can apply a override for Ext.form.Labelable here

Ext.override(`Ext.form.Labelable`, {
    labelableRenderTpl: 'Your Template'
});

This is untested but it should work cause a mixin is defined like any other class. What you need to know is that now all classes that are using this mixin will use the new template. In case of of lableable this list is short

  • Ext.form.FieldContainer
  • Ext.form.field.Base
  • Ext.form.field.HtmlEditor

If you don't want to change it for all you will need to create your own mixin for example by extending Ext.form.Labelable and override Ext.form.field.Base to apply it to all fields.

You may find some more information about overriding here. (Even if some of the SO community seems to not like this question for your case you may find some valuable information in there)

Update

As you already guessed the problem is that the mixin was already copied to the class the time the override get applied so this is all about timing and may be ending in a hard match. I would recommend you to inherit from the Ext.form.Labelable mixin and apply this new mixin to all classes you need by overriding the implementation with your new mixin.

Upvotes: 6

Related Questions