2

I'm wanting to add a new parameter (data-validate="parsley") to the Safecracker form tag. I know this isn't possible out of the box but was wondering whether it was possible to write a simple(ish) extension that could do it?

If anyone can give me some pointers, I'm willing to have a go.

Cheers

Jim

  • I need an answer on this one too, so chiming in so I get updates if someone has a solution. – Jean St-Amand Aug 21 '13 at 10:50
6

I've created an extension that'll let you do it.
https://github.com/jazonv/SafeCracker-HTML5-Attributes

In addition to data-foo="bar", it'll also lets you use autocomplete="no" and novalidate="novalidate".

(Inspired by this gist by Objective HTML)

Disclaimer:
I'm by no means a PHP/Add-on dev. I just wanted to 'have a go' too. Hopefully there's nothing wrong with it.
If any better-versed devs want to give it a once over, that'd be appreciated.

| improve this answer | |
  • Thanks so much for this Jason. I had no idea that Justin Kimbrell had already done something similar that you were able to adapt. I've tested the extension now and can confirm that it works! – Jim Pannell Aug 26 '13 at 9:45
  • Open source at it's finest folks. Again, nice work on this Jason. – Justin Kimbrell Aug 26 '13 at 14:19
  • No worries, glad to help. – Jason Varga Aug 27 '13 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.