# Hide fields on blueprint depending on parent template

**URL:** <https://forum.getkirby.com/t/hide-fields-on-blueprint-depending-on-parent-template/29303>\
**Category:** Questions\
**Tags:** v3\
**Created:** [August 16, 2023, 2:17pm UTC](https://forum.getkirby.com/t/hide-fields-on-blueprint-depending-on-parent-template/29303 "2023-08-16T14:17:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aba3aba](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@aba3aba](https://forum.getkirby.com/u/aba3aba)\
**Post date:** [August 16, 2023, 2:17pm UTC](https://forum.getkirby.com/t/hide-fields-on-blueprint-depending-on-parent-template/29303/1 "2023-08-16T14:17:44Z")

</div>

Hi,

I have a page with blueprint ‘Artwork’ that I used in two different places (Exhibition and Catalogue) within the site. I want to either set the a default pages field value on the child to its parent or remove that field if the Artwork was added from Catalogue page.

I have created a page model to populate a field, but at the moment I only got it working on an Info field which I can not use for conditions to hide the pages field on the child.

I saw there was proposal with a [pr](https://github.com/getkirby/kirby/pull/2815) to add kql to the default of a field but it seems it didn’t got merged.

I don’t know if the “hidden” field would be an option here, I couldn’t find much information on the [docs](https://getkirby.com/docs/reference/panel/fields/hidden).

What are the possibilities to limit the visibility or default value of some fields based on the parent template?

Thank you

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [August 16, 2023, 4:20pm UTC](https://forum.getkirby.com/t/hide-fields-on-blueprint-depending-on-parent-template/29303/2 "2023-08-16T16:20:52Z")

</div>

I have three thought trains that you my want to explore:

1. Programmable blueprints ([Programmable blueprints | Kirby CMS](https://getkirby.com/docs/cookbook/panel/programmable-blueprints)) where you could set the default via PHP depending on the parent. But it’s not a given, I am not sure if/how it is possible to retrieve the parent already during page creation (which is when the default would be written to the content file). So maybe not - even if it would be the most elegant one, if you could get it working. But could be hard.

2. Use the `page.create:before` hook ([Hooks | Kirby CMS](https://getkirby.com/docs/reference/plugins/extensions/hooks)) to check the new page’s parent and add the value depending on the parent.

3. Don’t use the same blueprint, but actually make it two. The normal one and then use [Reusing & extending blueprints | Kirby CMS](https://getkirby.com/docs/guide/blueprints/extending-blueprints) to create the 2nd one without much repetition of code.

---

<div class="post-metadata">

**Author:** ![aba3aba](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@aba3aba](https://forum.getkirby.com/u/aba3aba)\
**Post date:** [August 17, 2023, 6:37am UTC](https://forum.getkirby.com/t/hide-fields-on-blueprint-depending-on-parent-template/29303/3 "2023-08-17T06:37:52Z")

</div>

Thank you!

I had to change from `page.create:before` to `page.create:after` and it worked.

Here is the hook I am using:

```auto
'page.create:after' => function ($page) {
        if ($page->intendedTemplate() == 'artwork') {
          if ($page->parent()->intendedTemplate() == 'catalogue') {
            $page->update([
              'artist' => '- ' . $page->parent()->uuid()
            ]);
          }
        }
      }

```

I will try with the first option to see if I can get it working as well.
