whitebear
whitebear

Reputation: 12433

How can I use same column twice?

I have table which has two date time format.

fromDate (e.g) 2013-05-20 13:00:00
toDate  (e.g) 2013-05-20 15:00:00

I want to show data such as

date      |from |to
2013/5/20 |13:00|15:00

So I made this source code

public function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->add('fromDate',null,array('label' => 'Date','format' => 'yyyy-MM-dd'))
        ->add('fromDate',null,array('label' => 'from','format' => 'HH:mm:ss'))
        ->add('toDate',null,array('label' => 'to','date_format' => 'HH:mm:ss'))

but it shows.

Unknown or duplicate field name in list mapper. Field name should be either of FieldDescriptionInterface interface or string. Names should be unique.

How can I use same column twice? or How can I make it for this purpose?

Upvotes: 3

Views: 1155

Answers (1)

Baba Yaga
Baba Yaga

Reputation: 1819

By default this isn't possible in the sonata admin bundle.

You have 2 choices...:

  1. Create both fields in your entity (fromDate and fromTime) and use those
  2. Rewrite it yourself to a custom view

Upvotes: 3

Related Questions