Jump to content

Recommended Posts

Posted

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

Posted

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);
});
  • Like 3
Posted

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!

  • Like 4
Posted
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  :)

  • Like 5

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...