Jump to content

Inputfield question — superfast


Adam Kiss
 Share

Recommended Posts

Hey all, and prbably mainly Ryan!

Quickie—is there a way to get a list of textformatters used on field from inside the instance of inputfield upon loading the edit page?

Ex.: can i get a list of textformatters for 'body' from inside tinymce module when user opens edit page in admin with page that has 'body'?

If yes, how? Thanks

Link to comment
Share on other sites

Sure! You just need to know the name of the field (usually the same as the 'name' attribute) and then you can grab it directly from the Field object. Writing in browser here, but think it should work. It assumes you are somewhere in an Inputfield.

$field = wire('fields')->get($this->attr('name'));
if($field->textformatters) foreach($field->textformatters as $className) {
 echo "Name: $className";
}

Many Inputfield functions already receive a copy of the $field, in which case you can just use that ($field->textformatters) rather than figuring it out yourself. Only text fields will have a 'textformatters' array, and you'd want to double check that it's actually present before using it.

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