Jump to content

Hide a repeater item field at creation


da²
 Share

Recommended Posts

Hi,

When I click the "add" button on this repeater I want to hide a field inside depending on the value of other fields in the same page (but outside the repeater). So it should start with a hook and end with a:

myInpufieldField->collapsed = Inputfield::collapsedHidden;

But I can't find a way to access the input field. And not sure what kind of hook to use (ProcessPageEdit::buildForm, Inputfield::render, InputfieldRepeater::render°.

I struggle to access the inputfield inside an item of a repeater... Any idea?

Link to comment
Share on other sites

Posted (edited)

Thanks, I had to update to dev branch to make it work.

I'm still interested to know how to do this with a hook, because on another template the dependency is related to a parent page field value.

Edited by da²
Link to comment
Share on other sites

1 hour ago, da² said:

I'm still interested to know how to do this with a hook, because on another template the dependency is related to a parent page field value.

See this recent reply to a similar question:

I think render() is too late to apply collapsedHidden so hook InputfieldXXX::renderReadyHook() instead, but the same ideas apply.

You can get the page being edited via the ID in $input.

Link to comment
Share on other sites

Posted (edited)
38 minutes ago, Robin S said:

See this recent reply to a similar question:

I can't use a hook like Inputfield::render because I just found that $inputfield->collapsed = Inputfield::collapsedLocked; is not working (I still can edit the field). It's working only from a hook ProcessPageEdit::buildForm or buildFormContent.

I'm investigating how to implement this with buildForm, if you have an idea don't hesitate, I'm wasting so much time on this simple feature... ?
I also have to check if the field is inside the repeater, because there is also another instance on the page and I don't want to modify it.

Edited by da²
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...