regesh Posted September 15, 2022 Share Posted September 15, 2022 Any field has visibility option (showif) that works perfect with field in current template. But i need to compare with the field in parent page template. Is it possible? The task is like that: I have multiselect field in parent page - it is "Page Refference" field. And i need field in children page compare that there is some page selected in parent multiselect field for it to show in editor. Link to comment Share on other sites More sharing options...
elabx Posted September 15, 2022 Share Posted September 15, 2022 Maybe something like this, but I'm not entirely sure it will work, place it on ready.php: $wire->addHookBefore('Inputfield::render', function($event){ // the field where the field to hide exists $page = $inputfield->hasPage; $inputfield = $event->object; if($inputfield->name != "field_to_hide_if_parent") return; if($page->id){ // maybe check for children of specific type? if($page->parent->template == "specific_type_of_page"){ // the condition on the parent page? if($page->parent->multiselect_field->name == "some-name"){ $inputfield->collapsed = Inputfield::collapsedHidden; } } } }); 1 Link to comment Share on other sites More sharing options...
DV-JF Posted September 15, 2022 Share Posted September 15, 2022 @regesh Have a look at https://processwire.com/modules/custom-inputfield-dependencies/ You'll have multiple options to configure the visibility of fields and even the possibility to mark them as required if your selector is matching. It adds following options to the fields: 2 1 Link to comment Share on other sites More sharing options...
regesh Posted September 15, 2022 Author Share Posted September 15, 2022 oO! Thanks a lot guys! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now