/** * This isn't just the name of an input, it's a path pointing to an input. The * path is similar to a folder path: slash (/) means to descend into a subsection, * dot-dot-slash (../) means to ascend into the parent section. * After a series of slashes and dot-dot-slashes, there should be the name of an input, * which will be returned. * Eg, if you want the related input to be conditional on a sibling input name 'foobar' * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name * 'baz', use '../baz'. If you want it to be conditional on a cousin input, * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. * Etc * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false * @return EE_Form_Section_Base */ public function find_section_from_path($form_section_path) { //check if we can find the input from purely going straight up the tree $input = parent::find_section_from_path($form_section_path); if ($input instanceof EE_Form_Section_Base) { return $input; } $next_slash_pos = strpos($form_section_path, '/'); if ($next_slash_pos !== false) { $child_section_name = substr($form_section_path, 0, $next_slash_pos); $subpath = substr($form_section_path, $next_slash_pos + 1); } else { $child_section_name = $form_section_path; $subpath = ''; } $child_section = $this->get_subsection($child_section_name); if ($child_section instanceof EE_Form_Section_Base) { return $child_section->find_section_from_path($subpath); } else { return null; } }