labelInfo does not work

labelInfo does not work

rf1234rf1234 Posts: 2,986Questions: 87Answers: 421

I am currently translating Editor. Have tried labelInfo and fieldInfo as well. While fieldInfo works, labelInfo doesn't do anything at all. Any ideas what I could do about this?

e.field( 'contract.instrument' ).label('Instrument:')
                                    .labelInfo('hallo')
                                    .fieldInfo('selber hallo');

I have just downloaded the latest Editor version and I use it with Bootstrap.

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    labelInfo() and.fieldInfo() are properties of field() and fields(), not of label().

  • rf1234rf1234 Posts: 2,986Questions: 87Answers: 421
    edited May 2017

    That's what I thought, yes.

    This works for both label and fieldInfo:

    -
    e.field( 'contract.instrument' ).label('Test:').fieldInfo('lala');
    

    This does not work for labelInfo (only for label):

    -
    e.field( 'contract.instrument' ).label('Test:').labelInfo('lala');
    

    This works for label and fieldInfo but not for labelInfo:

    -
    e.field( 'contract.instrument' ).label('Test:').labelInfo('lala').fieldInfo('blablabla');
    

    This also works for label and fieldInfo but not for labelInfo:

    -
    e.field( 'contract.instrument' ).label('Test:');  
    e.field( 'contract.instrument' ).fieldInfo('bla bla:');  
    e.field( 'contract.instrument' ).labelInfo('hallo');
    
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    I must be missing something. I wouldn't have expected those results.
    Sorry I can't be more help. No doubt Allan will enlighten us.

  • rf1234rf1234 Posts: 2,986Questions: 87Answers: 421

    I guess so, tangerine :smile:

    Now I tried something else. I set the labeInfo in the respective Editor instance - and it works.

    fields: [ {
            label: "Instrument:",
            labelInfo: "english text",
            fieldInfo: "german text",
            name:  "contract.instrument",
            type:  "select",
            options: instrumentOptions
    }]
    

    Now I tried to change it programmatically later like this:

    e.field( 'contract.instrument' ).labelInfo('hallo');
    

    IT WORKS NOW but unlike fieldInfo it requires to be preset already in the Editor instance.

    Now it gets really weird:
    If i also want to change the label programmatically like this:

     e.field( 'contract.instrument' ).label('Test:');
     e.field( 'contract.instrument' ).labelInfo('hallo');
    

    it doesn't work any longer. I cannot change label and labelInfo programmatically at the same time!!

    Now I tried it with fieldInfo like this:

    e.field( 'contract.instrument' ).fieldInfo('Test:');
    e.field( 'contract.instrument' ).labelInfo('hallo');
    

    WORKS. So looks like labelInfo and label don't like each other. And labelInfo requires to be preset already in the Editor instance. while the others don't have this requirement.

  • rf1234rf1234 Posts: 2,986Questions: 87Answers: 421

    I have to correct myself in one point. LabelInfo does NOT require to be preset in the Editor instance.

    This works:
    e.field( 'contract.instrument' ).labelInfo('test').fieldInfo('more testing');

    If I add a line to also set label then labelInfo does not work any longer. Seems to get overwritten by label?!
    e.field( 'contract.instrument' ).labelInfo('test').fieldInfo('more testing');
    e.field( 'contract.instrument' ).label('Für:')

    The second line makes the labelInfo disappear. fieldInfo still works.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    I'm afraid that's a bug :(.

    What is happening is that field().label() writes HTML to an element which also contains the label message. Therefore the label message element is removed and destroyed.

    I don't think there is actually a workaround for that at the moment - at least not that I can see. It's going to require a fix in Editor. I'll post back when I've made the required change.

    Thanks for flagging this up.

    Allan

  • rf1234rf1234 Posts: 2,986Questions: 87Answers: 421
    edited May 2017

    if you use it for translation purposes and you do a page refresh each time someone changes the language the work around would be to have a variable in the Editor instance and assign the value to the variable before Editor is being called. That would effectively make field().label() redundant and you could still use field().labelInfo().

    var myLabel;
    
    if (lang === 'de') {
        myLabel = 'Hallo';
    } else {
        myLabel = 'Hello';
    }
    
    .............
    {
    label: myLabel,
    name:  "contract.instrument",
    type:  "select",
    options: instrumentOptions
    }
    

    this is even easier and no additional variable needed:

    {
        label: lang === 'de' ? 'Hallo' : 'Hello',
        name:  "contract.instrument",
        type:  "select",
        options: instrumentOptions
    }
    
  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Just a quick one to say that this has been resolved in source now, and will be included in 1.6.4 which will drop soon.

    Regards,
    Allan

This discussion has been closed.