Zend Framework, Doctrine 2 - Let's talk entities and forms

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
For some reason this didn't go through to contributors even though I'm subscribed so I'm trying here instead.

I was playing around with Symfony 2 and I really liked their model validation annotations and form builder so I decided to write something similar for Zend Framework and Doctrine 2. I'm somewhat rusty with form elements so I'm sure they will be refactored/redone in the future but they work pretty well for now. This is an early preview and should by no means be used in production. For more information, check out http://www.spiffyjr.me/2011/07/15/more-doctrine-2-and-zend-framework-integration-goodies/
Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

localheinz
Nice one!


I have been thinking about this as it would just make sense!


Best regards,

Andreas

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

RE: Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
I'm open to suggestions if you have them. Specifically on how to handle the
form elements better as they're a foreign subject for me currently.

-----Original Message-----
From: Andreas Möller [mailto:[hidden email]]
Sent: Friday, July 15, 2011 11:06 AM
To: SpiffyJr
Cc: [hidden email]
Subject: Re: [fw-general] Zend Framework, Doctrine 2 - Let's talk entities
and forms

Nice one!


I have been thinking about this as it would just make sense!


Best regards,

Andreas


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

Marco Pivetta
I implemented something similar, but in an ugly way (really similar to
procedural style, but I had to do it quick 'n dirty)...
Just take a look at this:

https://gist.github.com/1084994

The code you should look for goes from line 72 to 238... Ignore the ACL
stuff...
The rest is almost completely dirt (also consider that I had to play around
with it lots of times, running behind the requests of a crazy customer :P )

That big switch is probably a trouble, but I think you could use some
annotation class for form elements too...
You could have a field annotation that can generate a form element once you
invoke it, like:

$annotation = new \Spiffy\Annotation\FormElement\Textarea($options); //This
happens internally, in the annotationReader, therefore it will be fetched
from there...

$myFormElement = $annotation->createElement(stdClass $entity, $em,
$annotationReader); //form element with all needed validators and similars
coming from annotations...

Could this work for you?

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com



On 15 July 2011 18:07, Kyle Spraggs <[hidden email]> wrote:

> I'm open to suggestions if you have them. Specifically on how to handle the
> form elements better as they're a foreign subject for me currently.
>
> -----Original Message-----
> From: Andreas Möller [mailto:[hidden email]]
> Sent: Friday, July 15, 2011 11:06 AM
> To: SpiffyJr
> Cc: [hidden email]
> Subject: Re: [fw-general] Zend Framework, Doctrine 2 - Let's talk entities
> and forms
>
> Nice one!
>
>
> I have been thinking about this as it would just make sense!
>
>
> Best regards,
>
> Andreas
>
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
This is interesting. I’ll look at it in more depth tonight. Thanks!

 

From: Marco Pivetta [mailto:[hidden email]]
Sent: Friday, July 15, 2011 11:27 AM
To: Kyle Spraggs
Cc: Andreas Möller; [hidden email]
Subject: Re: [fw-general] Zend Framework, Doctrine 2 - Let's talk entities
and forms

 

I implemented something similar, but in an ugly way (really similar to
procedural style, but I had to do it quick 'n dirty)...
Just take a look at this:

https://gist.github.com/1084994

The code you should look for goes from line 72 to 238... Ignore the ACL
stuff...
The rest is almost completely dirt (also consider that I had to play around
with it lots of times, running behind the requests of a crazy customer :P )

That big switch is probably a trouble, but I think you could use some
annotation class for form elements too...
You could have a field annotation that can generate a form element once you
invoke it, like:

$annotation = new \Spiffy\Annotation\FormElement\Textarea($options); //This
happens internally, in the annotationReader, therefore it will be fetched
from there...

$myFormElement = $annotation->createElement(stdClass $entity, $em,
$annotationReader); //form element with all needed validators and similars
coming from annotations...

Could this work for you?

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com




On 15 July 2011 18:07, Kyle Spraggs <[hidden email]> wrote:

I'm open to suggestions if you have them. Specifically on how to handle the
form elements better as they're a foreign subject for me currently.


-----Original Message-----
From: Andreas Möller [mailto:[hidden email]]
Sent: Friday, July 15, 2011 11:06 AM
To: SpiffyJr
Cc: [hidden email]
Subject: Re: [fw-general] Zend Framework, Doctrine 2 - Let's talk entities
and forms

Nice one!


I have been thinking about this as it would just make sense!


Best regards,

Andreas


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]



 

Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

localheinz
How about using annotations for generation of form elements?


Best regards,

Andreas

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
In reply to this post by SpiffyJr
That's not a bad idea at all but I still want a standard form class because there's always times when you need more customization than a generator can provide. I'll see if I can add something when I add filters to the annotations.

----- Reply message -----
From: "Andreas Möller" <[hidden email]>
To: "Kyle Spraggs" <[hidden email]>
Cc: "Marco Pivetta" <[hidden email]>, "<[hidden email]>" <[hidden email]>
Subject: [fw-general] Zend Framework, Doctrine 2 - Let's talk entities and forms
Date: Sat, Jul 16, 2011 5:04 am


How about using annotations for generation of form elements?


Best regards,

Andreas
Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
Okay, I updated the GitHub repository. Added the README.md, filter annotations, automaticValidators flag, automaticPersistancy flag, and automaticFilters flag. Also refactored the add() method.
Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

RE: Zend Framework, Doctrine 2 - Let's talk entities and forms

SpiffyJr
In reply to this post by localheinz
Does anyone have any input on how I should handle filters? I was thinking of
doing the following:

get($field) - applies filtering to the field

// user getter
getEmail() {
        return $this->get('email');
}

This allows users to have the flexibility of choosing whether or not to
include automated filtering for getters/setters. I really dislike magic
methods (__get/__set) so I'd prefer not to use them if at all possible.


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Kyle S
blogs @ www.spiffyjr.me
github @ www.github.com/spiffyjr
follow @ www.twitter.com/spiffyjr
Reply | Threaded
Open this post in threaded view
|

Re: Zend Framework, Doctrine 2 - Let's talk entities and forms

Bart McLeod


Op 18-07-11 17:05, Kyle Spraggs schreef:

> Does anyone have any input on how I should handle filters? I was thinking of
> doing the following:
>
> get($field) - applies filtering to the field
>
> // user getter
> getEmail() {
> return $this->get('email');
> }
>
> This allows users to have the flexibility of choosing whether or not to
> include automated filtering for getters/setters. I really dislike magic
> methods (__get/__set) so I'd prefer not to use them if at all possible.
Magic getters and setters are considered a great feature by others,
including me. Zend_Framework uses their magic extensively. If
implemented well, these functions offert great possibilities. I do not
think personal dislike is a good reason not to use them if you plan to
develop for a large community.
-Bart
>

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]