Updating the value of a tags type field

Hi Community and Support Team :v:!

There is a possibility, that when the positions field inside the blueprint cards.yml is updated.

The stored value that was initially assigned to the child page with the position field is automatically updated.

For example:


Parent blueprint:

:file_folder: route: site/blueprints/pages/cards.yml

title: Cards
files: false
pages:
  template: card
fields:
positions:
  label: Positions for employees within the company
  type: tags
  help: For example: Financial Advisor, Manager, etc.

Children blueprint:

:file_folder: route: site/blueprints/pages/card.yml

title: Card
files: true
pages: false
fields:
position:
  label: Position (Select an option)
  required: true
  help: Obligatory field
  type: select
  min: 1
  max: 1
  options: query
  query: page.parent.positions.split(",")

Result:

:file_folder: route: content/cards/cards.txt

:page_facing_up: file: cards.txt


Title: Cards

----

Positions: Financial Advisor, Manager, Technical support

Children:

:file_folder: route: content/cards/test-card/card.txt

:page_facing_up: file: card.txt


Title: Test Card

----

Position: Manager

:repeat: Positions field update

Old: Manager
New: Financial Manager

Updating the position value of all the pages that have the Manager value in the position field with the new Financial Manager value.


:arrow_heading_down: Final result in automatic:

Title: Test Card

----

Position: Financial Manager

I await your response and help please.

Thank you very much.

Regards!

You could do it with a hook, that updates all fields when the underlying field is changes. But I think that’s not such a great idea. Instead, I’d work with key/value pairs in a structure field, where the value would ideally always stay the same and only the display title would be updated. That way, you wouldn’t have to change the values of the dependent fields but just fetch the title that corresponds to the stored value from the original structure field

Hi @texnixe !

OK perfect.

Thank you very much for the answer and help.

I’m going to try to solve it with a field of type structure.

Anything or doubt I will post in this thread.

Regards!

Hi @texnixe !

Try to update the position field using the positions parent field of type structure. But upon upgrade the mapping inside my card.yml page is lost.

Parent blueprint:


positions:
  label: Positions for employees within the company
  type: structure
  fields:
   key:
     label: Key
     type: text
     width: 1/3
     icon: key
   name:
     label: Name
     type: text
     icon: user
     width: 2/3
  help: For example: Financial Advisor, Manager, etc.

Children blueprint:


position:
    label: Position (Select an option)
    required: true
    help: Obligatory field
    type: select
    min: 1
    max: 1
    options: query
    query:
      fetch: page.parent.positions.toStructure
      text: "{{ structureItem.name }}"
      value: "{{ structureItem.key }}"

Problem:



NOTE: When updating the parent field called structure type positions. My underlying field loses the assigned value and doesn’t update automatically.

I await your response and help please.

Regards!