Jump to content

Change visibility of a Repeaters Child Fields based on owner pages field value


guy
 Share

Recommended Posts

I'm looking to change the visibility of child fields within a repeater based on the value of a field on the owner page (the page on which that repeater appears).

To illustrate:

Owner (Page)
  - type (select field)
  ---- type_one (option)
  ---- type_two (option)

  - things (repeater field)
  ---- thing_one (child field)
  ---- thing_two (child field)

With the above set up, when you select type > type_one then within the repeater the visibility of things > thing_two would be set to hidden.

I don't mind how I go about doing this - at present I've tried the following hook within ready.php:

$wire->addHookAfter('ProcessPageEdit::buildFormContent', function (HookEvent $event) {

    $page = $event->object->getPage();

	$form = $event->return;

	$thingsField = $form->getChildByName('things');

	... // but past this point I haven't been able to select $thingsField child input fields

});

The above gets me access to an InputfieldRepeater as $thingsField but I'm not sure how to then drill down into its child input fields.

If I could get access to child input fields I'd then assume I can set showIf to a nonsense value to hide the field, i.e.

$childInputField->showIf = 'true=false';

Any help with the above would be much appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...