ng-admin: How can I make choices field dynamic based on entry?

187 Views Asked by At
.fields([
  nga.field('city', 'reference')
    .validation({ required: true })
    .targetEntity(ds)
    .targetField(nga.field('city'))
    .label('City'),
  nga.field('LS1', 'choice')
    .choices(function(entry) {
      console.log(entry);
      if(entry.values.city) {
        return data[entry.values.city];
      }
      return data[1];
    })
    .validation({ required: true }),
  nga.field('ls', 'choices')
    .choices(function(entry) {
       if(entry.values.city) {
         return data[entry.values.city];
       }
       return data[4];
     })
    .validation({ required: true })
    .label('ls'),

choice field has access to entry values and get refreshed when city value is entered.I need to have multi-choice for "ls" field depending on what is entered in "city" field."data" is prepared in "prepare" function of creation view.Is there any other way by which I can show multi-choice list based on value of "city" field.Any help is highly appreciated.

0

There are 0 best solutions below