Adam Kiss Posted November 30, 2012 Posted November 30, 2012 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
ryan Posted December 2, 2012 Posted December 2, 2012 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. 1
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