A
A
Alexander Kovalchuk2016-01-10 18:55:17
Laravel
Alexander Kovalchuk, 2016-01-10 18:55:17

How can administrator frozennode for name_field in relationship select value from multiple table fields?

I have a many-to-many relationship and the code looks like this

'apartments' => [
    'type' => 'relationship',
    'name_field' => 'address',
],

The result is this view because there are several apartments in one building
f94cad3a5609482f8e95d247dd775f5b.png
How to add the apartment number before 'name_field' => 'address'?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2016-01-10
@mamut

I have already written many times: do not use this craft for anything that is more complicated than the ToDo list.
You can't even open the documentation and read 5 lines of text.
administrator.frozennode.com/docs/field-type-relat...
Use the overloaded accessor for the apartment_address field as the name_field .
That is, add to the model:

public function getAddressApartmentAttribute() {
  return $this->attributes['квартира'] . " - " . $this->attributes['address'];
}

And correspondingly:
'apartments' => [
    'type' => 'relationship',
    'name_field' => 'address_apartment',
],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question