Get selected item text on section text/info

My page blueprint:

orderStatus:
    label: Order Status
    type: select
    translate: false
    required: true
    default: pending
    options:
        pending: Pending
        pending_payment: Pending Payment
        ...

My section bluprint:

type: pages
headline: Last Orders
parent: site.orders
sortBy: createdAt desc
info: "{{ page.orderStatus }}"
image: false

I want show order status on section info.
But showing selected value instead of selected text.

com_panel_site

Current: output: pending_payment
Expected output: Pending Payment

Tried followings:

  • page.orderStatus.text
  • page.orderStatus.value
  • page.orderStatus.toText()

Is there a way to solve this?
Thanks

Yes, but you need a custom field method that reads the corresponding text from the blueprint (or you create an options array with those key-value pairs and have your custom read method fetch the value from there.

Awesome! Thank you so much :ok_hand:

Maybe it will help the solution that following codes:

sections/orders.yml

type: pages
headline: Last Orders
parent: site.orders
sortBy: createdAt desc
info: "{{ page.orderStatusText }}"
image: false

models/order.php

class OrderPage extends BaseModel
{
    public function orderStatusText()
    {
        $field = $this->blueprint()->field('orderStatus');
        return $field['options'][$this->orderStatus()->value()];
    }
}