View Full Version : [ HOW-TO ] Extend getXXX Model/storefor grid, form, ...

30 May 2013, 4:56 AM
Hi all,

I'll explain my will and hope someone could perhaps help me finding the best way to do it.
I have store with i18n datas.
My API return this :

name: 'monvelo',
name_default: 'mybike',
description: null,
description_default: 'lorem ipsum',
slug: 'mybi',
cost: 12,
},{...}, ...

I would like to display the xxx_default value when xxx is empty.
But I want to create real good code so that it would be automatic for each new store/model.
In facts, I would to find the best method(s) to extend so that grid, forms, ... get the right value.

I thought about extending store.load, model.getData, model.getFields but for example, I miss the values while loading a grid with a store

Thanks in advance for any tips.


2 Jun 2013, 9:30 PM
I'm not quite sure what you're looking to do based on your description, but you mentioned setting a default value. Perhaps this is what you're looking for?

2 Jun 2013, 10:47 PM
Thank you but it is not the field default value that I want to extend but the record value.
In the record, if the field xx is empty and the field xxx_default is not, take the xx_default.

This is simple but the place where I should extend in order to work in forms, grid ... is not at all.

4 Jun 2013, 1:05 PM
If field A needs to evaluate field B in a record to determine what value field A will have you might use the field's convert method to evaluate the record before setting the value: