labelSymbol

Post modules, themes or any other code you want to share with the community.

Moderator: Developers

alessandro.gagliano
Posts: 12
Joined: Thu Mar 05, 2009 9:07 am

labelSymbol

Postby alessandro.gagliano » Sat Mar 01, 2014 11:46 am

Hi,

this override add the "labelSymbol" config param for fields in form layout.

usage examples:

Code: Select all

new GO.form.NumberField({
  name:'price',
  fieldLabel:'Price',
  labelSymbol:GO.settings.currency
});

new GO.form.NumberField({
  name:'rate',
  fieldLabel:'Rate',
  labelSymbol:'%'
});

new GO.form.NumberField({
  name:'phone',
  fieldLabel:'Phone',
  labelSymbol:'☎'
});


override code

Code: Select all

Ext.override(Ext.layout.FormLayout, {
   getTemplateArgs: Ext.layout.FormLayout.prototype.getTemplateArgs.createInterceptor(function(field) {
      if (!field.hideLabel && field.labelSymbol) {
         var os = '<span style="display:inline-block;float:%;">';
         var cs = '</span>';
         var ls = Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator;
         field.labelSeparator = '';
         if (field.fieldLabel) {
            field.fieldLabel = field.fieldLabel + ls;
         }
         field.fieldLabel = (field.fieldLabel ? os.replace('%', 'left') + field.fieldLabel + cs : '') + os.replace('%', 'right') + field.labelSymbol + cs;
      }
   })
});


Regards,
Alessandro Gagliano
mschering
Site Admin
Site Admin
Posts: 8154
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: labelSymbol

Postby mschering » Wed Mar 05, 2014 1:18 pm

Why wouldn't you just add that to the fieldLabel prop?
Best regards,

Merijn Schering
Intermesh
alessandro.gagliano
Posts: 12
Joined: Thu Mar 05, 2009 9:07 am

Re: labelSymbol

Postby alessandro.gagliano » Thu Mar 06, 2014 5:52 am

labelSymbol is right aligned respect to fieldLabel, as in attached picture
Attachments
labelSymbol.jpg
labelSymbol.jpg (2.63 KiB) Viewed 1611 times
mschering
Site Admin
Site Admin
Posts: 8154
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: labelSymbol

Postby mschering » Thu Mar 06, 2014 11:28 am

Aha, that looks nicer indeed!
Best regards,



Merijn Schering

Intermesh

Return to “Contributed development”

Who is online

Users browsing this forum: No registered users and 1 guest