da² Posted June 20 Share Posted June 20 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 More sharing options...
Robin S Posted June 20 Share Posted June 20 I think you could use an inputfield dependency for this, with the "forpage" keyword: https://github.com/processwire/processwire/pull/255 2 Link to comment Share on other sites More sharing options...
da² Posted June 21 Author Share Posted June 21 (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 June 21 by da² Link to comment Share on other sites More sharing options...
Robin S Posted June 21 Share Posted June 21 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 More sharing options...
da² Posted June 21 Author Share Posted June 21 (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 June 21 by da² 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