Examples of Aura.Input and Aura.Filter working together?

107 views
Skip to first unread message

ZombieSplat

unread,
May 9, 2016, 7:36:25 AM5/9/16
to The Aura Project for PHP
It's probably because I am working on this while I'm tired, but I'm having trouble figuring out how to get all these pieces to fit together. Ultimately I would love an example of the two packages working together where the form is trying to not only validate, but sanitize the input.

I have been able to figure out how to get Aura.Input to sanitize and validate inputs using an anonymous function. but I really don't want to write the same thing over and over again so I want to put common tasks in classes using the __invoke method or something. So after some looking around it seemed like Aura.Filter was the right answer, but I couldn't seem to figure out how to make these two packages talk nicely to eachother.

I tried writing my own FilterInterface and for some reason I couldn't get the input to pass back to the object with my sanitizations.

Thanks in advance for any help.


Hari K T

unread,
May 9, 2016, 10:33:27 AM5/9/16
to aur...@googlegroups.com
Hi, 

I believe you are trying to integrate Aura.Input  ( v1 ) with Aura.Filter ( v2 ) package. 

If you are trying both v1 packages, here is an example : https://github.com/harikt/phpform/tree/develop .

To make it work with v2 of Aura.Filter you need to implement FilterInterface[1] .

Create a class that extends SubjectFilter [2] which implement FilterInterface[1] .

The assert[3] or apply is what need to be called inside the values method . 

Similarly implement the getFailures() method calling getMessages() [ 4 ] and getMessagesForField($field) [ 5 ] .

Once you are done with it, you can pass the class to newSubjectFilter or use some sort of di container like Aura.Di to build the filter and pass to the form.

There is a bit of work to make things work, but hopefully you will understand the inner working of Aura better once you are done :-) .

Good luck! .



Hari K T

You can ring me : +91 9388 75 8821

Skype  : kthari85
Twitter : harikt

--
You received this message because you are subscribed to the Google Groups "The Aura Project for PHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to auraphp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ZombieSplat

unread,
May 11, 2016, 12:12:40 PM5/11/16
to The Aura Project for PHP
you are correct, I was trying to use different versions.

Now that I am in and playing with version 1 I am wondering how you're using Filter v2 or 3? in conjunction with what?

Hari K T

unread,
May 12, 2016, 12:53:47 AM5/12/16
to aur...@googlegroups.com
Hi, 

you are correct, I was trying to use different versions.

Now that I am in and playing with version 1 I am wondering how you're using Filter v2 or 3? in conjunction with what?

You may want to read once more my message regarding how to use v2 filter with v1 input to achieve the same.

kenneth....@gmail.com

unread,
Jan 7, 2017, 6:22:06 PM1/7/17
to The Aura Project for PHP
I am following "https://leanpub.com/aurav2/read" to teach myself Aura 2.  I like it.  It is fast.  However, the examples use foa/filter-input-bundle, and this depends on Aura\Filter\RuleCollection, which only exists in aura/filter version 1.x.  The Aura 2 docs refer to using Aura\Filter\RuleCollection as though it was not supposed to go away in Aura 2, yet I cannot find it in any version 2.x package.   Can you confirm its removal in Aura 2?

Hari K T

unread,
Jan 20, 2017, 12:26:56 AM1/20/17
to The Aura Project for PHP
Hi, 
 
I am following "https://leanpub.com/aurav2/read" to teach myself Aura 2.  I like it.  It is fast. 

Happy to hear your feedback.
 
However, the examples use foa/filter-input-bundle, and this depends on Aura\Filter\RuleCollection, which only exists in aura/filter version 1.x.  The Aura 2 docs refer to using Aura\Filter\RuleCollection as though it was not supposed to go away in Aura 2, yet I cannot find it in any version 2.x package.   Can you confirm its removal in Aura 2?

Sorry that the docs are not up-to date.

Aura.Filter v2 wasn't released when I was writing the docs for the framework. Also Aura.Input was easy to configured with Aura.Filter v1 . ie why it happened to be there.

I have made changes for Aura.Input to move to 3.x . There are a few feedback I am waiting before I go for a release. 


Basically it is about splitting some of the interfaces of Aura.Filter and Aura.Input . May want to ping Paul M Jones to see what he thinks about the same.

Thank you.
Reply all
Reply to author
Forward
0 new messages