Robin S Posted February 2, 2017 Share Posted February 2, 2017 I am hooking an inputfield render() method, and I'm hoping to be able to get the $field object that this inputfield is for. I can see the $field object in Tracy but cannot access that directly in the hook. Is there a trick I'm missing? More broadly, my objective is to match the inputfield to its field when the inputfield is rendered inside a Repeater. When the inputfield isn't inside a repeater you can easily work out the field because the name attribute of the inputfield is the same as the field name. But when inside a repeater the name attribute has a repeater suffix appended, e.g. "my_field_repeater1125". The integer at the end is a page ID so that can potentially be any length, and I don't want to do something like trim the name from "_repeater" onwards as someone could conceivably use the string "_repeater" in their field name. Any suggestions? Link to comment Share on other sites More sharing options...
Robin S Posted February 2, 2017 Author Share Posted February 2, 2017 Right after posting that I started thinking clearly... $inputfield = $event->object; $field = $this->fields->get($inputfield->name); if(!$field) { $name = substr($inputfield->name, 0, strpos($inputfield->name, "_repeater")); $field = $this->fields->get($name); } 3 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