thomas Posted October 8, 2015 Posted October 8, 2015 I am building an angular app with Processwire and in order for the forms to work I need 'ng-model="<?=$field->name;?>"' added to every Inpufield. Now this doesn't work all the time. I am macgyvering my way through the Hooks now to add the attribute to radios and selects but it would be nice to have it for every Inputfield. Thanks, thomas
LostKobrakai Posted October 8, 2015 Posted October 8, 2015 The form api of processwire isn't meant to be used in the frontend, therefore I doubt there being any updates like that. But you can add that functionality on your own. $wire->addHookBefore("Inputfield::render", function(HookEvent $event){ $inputfield = $event->object; $inputfield->attr("ng-model", $inputfield->name); }); 3
adrian Posted October 8, 2015 Posted October 8, 2015 This seems to work on all inputfields for me: $this->addHookBefore('Inputfield::render', function($event) { $field = $event->object; $field->setAttribute('ng-model', $field->name); }); EDIT: Oops - well and truly beaten Can't afford to sidetracked in the middle of replying with when @LostKobrakai is online! 4
thomas Posted October 8, 2015 Author Posted October 8, 2015 Is there a way to set the attributes of Checkbox Options? Thanks, thomas
tpr Posted October 8, 2015 Posted October 8, 2015 Can't afford to sidetracked in the middle of replying with when @LostKobrakai is online! So true! He's possibly a before hook on topic::render 5
LostKobrakai Posted October 8, 2015 Posted October 8, 2015 @tpr If so I'd post even before the starting post, which is not the case. q.e.d.
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