Gideon So Posted March 1, 2017 Share Posted March 1, 2017 I have a repeater matrix field in which there is a repeater field that container a textarea field. How can I search text in the textarea?? I tried $pages->find("repeater_matrix_field.repaeter_field.textarea=%$q"), but return no results. Any idea how to do it?? Gideon Link to comment Share on other sites More sharing options...
kongondo Posted March 1, 2017 Share Posted March 1, 2017 I am not saying it will work, but for starters, your selector operator is wrong: 14 minutes ago, Gideon So said: =%$q That should be: %=$q Link to comment Share on other sites More sharing options...
tooth-paste Posted March 1, 2017 Share Posted March 1, 2017 or Quote field.repaeter field.repeater Link to comment Share on other sites More sharing options...
Gideon So Posted March 1, 2017 Author Share Posted March 1, 2017 46 minutes ago, tooth-paste said: or field.repeater Correct a typo here doesn't help much. ?? Gideon Link to comment Share on other sites More sharing options...
Gideon So Posted March 1, 2017 Author Share Posted March 1, 2017 2 hours ago, kongondo said: I am not saying it will work, but for starters, your selector operator is wrong: That should be: %=$q Hi, Typo here. I think I use the right operator in my code. Any more suggestions? Gideon Link to comment Share on other sites More sharing options...
Robin S Posted March 1, 2017 Share Posted March 1, 2017 This syntax works fine for me with plain Repeater fields, so it should work for Repeater Matrix fields too: $results = $pages->find("my_repeater.my_nested_repeater.my_textarea%=foo"); So maybe typos are slipping in somewhere else... Testing this did expose a bug where pages are matched when the repeater fields are empty - will file this at GitHub shortly. Done: https://github.com/processwire/processwire-issues/issues/205 There is another way you could do this, but I think the selector with subfields is more elegant... // returns the root container page for any repeater item no matter how deeply nested function getRootContainer($page) { if($page instanceof RepeaterPage) { return getRootContainer($page->getForPage()); } else { return $page; } } $results = new PageArray(); $repeater_pages = $pages->find("my_textarea%=foo, has_parent=2, include=all"); foreach($repeater_pages as $repeater_page) { $results->add(getRootContainer($repeater_page)); } 3 Link to comment Share on other sites More sharing options...
Gideon So Posted March 2, 2017 Author Share Posted March 2, 2017 2 hours ago, Robin S said: This syntax works fine for me with plain Repeater fields, so it should work for Repeater Matrix fields too: $results = $pages->find("my_repeater.my_nested_repeater.my_textarea%=foo"); Hi @Robin S, I have tried this syntax. Here is my line of code. $pages->find("repeater_matrix_field.repeater_field.textarea%=$q"). it seems that it does not work in repeater in a repeater matrix context. It still return no results. Gideon Link to comment Share on other sites More sharing options...
Gideon So Posted March 4, 2017 Author Share Posted March 4, 2017 Hi, The solution is simple. $pages->find("my_repeater_matrix.my_repeater.my_textarea_field%=$q"); I think I messed up with field name before. Gideon 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