Jump to content

Selector for fields with a given textformatter


Robin S
 Share

Recommended Posts

Is it possible to use a selector to find fields that have a given textformatter applied?

I tried...

$flds = $fields->find("textformatters=TextformatterHannaCode");

...but the textformatters property is an array so I get an array to string conversion error. So a broader question would be: is it possible to use a selector to match inside a property that is an array?

For the textformatter, is there a more efficient way than just iterating over $fields?

$flds = [];
foreach($fields as $field) {
	if( is_array($field->textformatters) && in_array('TextformatterHannaCode', $field->textformatters) ) $flds[] = $field;
}

 

  • Like 2
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...