bummzack / silverstripe-omnipay-ui

UI components for SilverStripe Omnipay Module
BSD 3-Clause "New" or "Revised" License
5 stars 9 forks source link

Payments tab localization #6

Open digitall-it opened 8 years ago

digitall-it commented 8 years ago

I can't localize the Payments tab on my model, I can't understand if I did something wrong or there's a problem somewhere.

I installed the silverstripe omnipay module. My model is called ShopOrder, so in my config yaml file I said

ShopOrder:
   extensions:
     - Payable
Payment:
  has_one:
    Order: ShopOrder

I looked at my model admin area, there was a Payments tab, with the ability to add new payments right from there.

Then installed the bummzack omnipay ui, and updated my config yaml file:

ShopOrder:
   extensions:
     - Payable
     - PayableUIExtension
Payment:
  has_one:
    Order: ShopOrder

In the ShopOrder model admin area, the Payments tab lead to a slightly different interface: I couldn't add new Payments from there now.

So I knew the PayableUIExtension was working, by the removeComponentsByType and addComponent commands.

The problem is, the PayableUIExtension calls this code in the updateCMSFIelds function:

$fields->push(TabSet::create('Root', $paymentTab = new Tab('Payments')));
$paymentTab->setTitle(_t('PayableUIExtension.PaymentsTab', 'Payments'));

but this has no effect: the Root.Payments tab has already been created by Omnipay, so the tab is already there.

The following code:

$fields->addFieldToTab('Root.Payments',GridField::create('Payments', _t('Payment.PLURALNAME', 'Payments'), $this->owner->Payments(), $gridConfig));

then adds the gridfield to the already existing tab.

The problem is that as the tab already exists, it's title cannot be translated. It should become

$paymentTab = $fields->fieldByName('Root.Payments');
$paymentTab->setTitle(_t('PayableUIExtension.PaymentsTab', 'Payments'));
bummzack commented 8 years ago

There shouldn't be a Payments tab being created by omnipay, since the omnipay module itself doesn't add any fields…

But I think the issue is already fixed in Master. Can you try with the master branch and see if that solves your problem?