Monday, April 13, 2015

Re: How to set class on form template node with {{attrs}} defined?

I had another look at the code and found that this seems to be a tough nut to crack.
Since some templates are called directly from the form helper methods and some attributes get set inside the widgets it is a bit of a problem setting a default class via a single method or in a single place.
The reason I needed to set a class was for jquery to execute operations on the input elements.
I have decided to create a custom html attribute instead called "render" and invoke it like so: $('[render="wysiwyg"]').....;
Now I can just extend the form helper's input function and add the required render method to the options from my field configuration registry.
Would be great if we were able to set default or primary attribute values via the theme but I fear the template method might make this near impossible right now.

My problem is resolved but if there is a better way of doing this, please let me know.
Thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: