Hi William,

I'm not sure if I get what you want, but if the issue is populating 2
form fields with entries from the same Model using one of the model
properties as a sort of "filter" for each form field, then you can use
a custom query to populate the form field. You basically have to
create 2 Doctrine form widgets on your form (for example, two
sfWidgetFormDoctrineSelect widget) passing the "query" option when
creating them. So, on your Form code, adding something like this:

$this->widgetSchema['cv_select'] = new sfWidgetFormDoctrineSelect(array
(
  'model' => 'Document',
  'query' => $cv_query
));

$this->widgetSchema['letter_select'] = new sfWidgetFormDoctrineSelect
(array(
  'model' => 'Document',
  'query' => $letter_query
));

Of course, you'll have to create the two custom Doctrine queries (I
named them $cv_query and $letter_query on this example) using the type
field to filter what each widget will display, but I think you can
handle that part - the trick is passing the query option when creating
the widget.

More info here: 
http://www.symfony-project.org/api/1_2/sfWidgetFormDoctrineSelect

Hope that was helpful!

Kind Regards,
Thiago Campezzi


On Jun 20, 9:22 pm, William <william.dura...@gmail.com> wrote:
> Hi Alexandru,
> i'm so sorry for this "resend" of my message, there was a bug that
> resent my message, I had deleted them (as soon as i've seen it).
> I know tha some of us are busy or might not reply anything.
>
> I've ever thought to split CVs from letters, but i would like to know
> if i could be in a different way.
> Gonna to explain a bit more :
> - I've an object Document with its attributes : filename, description,
> type...
> - Type attribute can be CV or Letter.
> - I've an another object Mail (one field is document_list) that has
> m2m relation with Document.
> - Some restrictions : a Mail can have 2 Document objects max : 1 CV
> and 1 Letter.
> No logical problem i think. The only problem is to split one form
> field into two : a select with just Documents thave have CV type and
> an another one that just have Letter type.
> I'm using Symfony 1.2 and Doctrine. In 1.0, i could be what you said
> but in 1.2 don't know how to do.
> Else, i'll rebuild my model by adding two attributes document_cv_id
> and document_letter_id in my Mail object.
> What do you think about it ?
>
> Thanks for your reply and sorry for multiple messages.
> William.
>
> On 20 juin, 23:09, Alexandru-Emil Lupu <gang.al...@gmail.com> wrote:
>
> > HI william!there is no valable reason to do this "resend" of your message,
> > in that short interval (4 mails in 2 hours). If you did not got any replies,
> > it's maybe because some of us might not know what to answer, or maybe we're
> > out. it is still (was for me ) Saturday.
>
> > And, for your question, If you ask us how to solve it, then obviously you
> > have a logic problem. For a start i would split CVs from letters, and i
> > would use a relational table: to keep the track of what letter was attached
> > to the CV. From what i may understand from your question, it might be a job
> > offer website.
>
> > IF you use Propel:
> > You might wanna use 2 custom Peer functions that are using "doSelect"
> > function.
>
> > public static function getCVs(Criteria $c){
> > $cv = array();
> > $c = clone $c;
> > $results  = self::doSelect($c);
> > foreach ($results as $document){
> > if ($document->isCV()){
> > array_push($cv,$document)}
> > }
>
> > return count($cv)>0 ? $cv : null;
>
> > }
>
> > public static function getLetters(){
> > $letter = array();
> > $c = clone $c;
> > $results  = self::doSelect($c);
> > foreach ($results as $document){
> > if ( ! $document->isCV()){
> > array_push($letter,$document)}
> > }
>
> > return count($letter)>0 ? $letter : null;}
>
> > public static function doSelect($c){
> > if (!isset(self::$list_of_documents)){
> > $c = clone $c;
> > self::$list_of_documents = parent::doSelect($c)
>
> > }
>
> > return self::$list_of_documents;
>
> > }
>
> > if your problem was that you need to make 2 queries, well that's the
> > solution, however, but, i would suggest that $list_of_documents to be an
> > array having as key a hash after the serialization of the Criteria object.
> > Just to be sure that you will be able to make another doSelect intergation
> > with another Criteria.
>
> > Alecs
>
> > On Sat, Jun 20, 2009 at 2:33 PM, William <william.dura...@gmail.com> wrote:
>
> > > Hi,
>
> > > I have to do two list select from the same object model. How can i
> > > do ?
> > > I've an object Document which contains CVs and letters. I must split
> > > them in a form.
> > > A mail can have 0, 1 or 2 documents : the user have to make his own
> > > choice in a select for CVs and and an another select for letters.
> > > How can i do ? Might i use extra fields ? and merge result in action ?
>
> > > Thanks.
>
> > --
> > I am on twitter:http://twitter.com/alecslupu
> > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > Tel: (+4)0748.543.798
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to