Hi,

In the BaseDoctrineForm, in the ::configure() method, I've coded something
like this:

$aConditions = array('ajax'=>isAjax ? 'ajax:false, 'new'=> isNew ? 'new':
false, 'embedded'=>isEmbedded?'embedded':false, ....);
$method = sprintf('_computeFields%s%s%s', $aConds['ajax'], $aConds['new'],
$aConds['.....)

and finally
try{
$this->useFields($this->$method());
}catch(Exception $e){}

So I can compute the correct method to call to configure the fields
according to the current situation.

In the embedRelations, you can give args to the newed form class, this is
where you'll give to it "you are currently embedded" and why not pass it the
current embedding form and other needed stuffs.

The main concern here is to make the form class able to determine "by
itself" how it should react to its external conditions, without having to
tell how it should act (what fields it should show, etc) everywhere in the
code. This make these available in some places (the
"_configureFields%s%s%s..' methods). You can even go further by making an
"order of precedence" (like ysfDimensionPlugin does in someway).

So there is no more questions such as "where is it said that this form show
these fields ?", it's all in these methods of the concerned form.

Hope this help,

Cheers,

Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!


On Wed, Feb 17, 2010 at 8:12 PM, Daniel Lohse
<annismcken...@googlemail.com>wrote:

> Hey there,
>
> there's only one way I can of, which you probably won't like. Just
> configure all the fields directly in the form. :)
> So, delete the form: display: key and just create another form inheriting
> from the form you are probably already using elsewhere and use
> $this->useFields() before calling this embedRelations().
>
> Does that help? By the way, you really shouldn't use the form: display: key
> as you are likely to get confused and forgot to update the generator.yml
> when new fields are added. This is also prevents a security hole.
>
>
> Cheers, Daniel
>
> On 17.02.2010, at 19:01, Mikael wrote:
>
> > Hello,
> >
> > I've installed the ahDoctrineEasyEmbeddedRelationsPlugin and set it up
> > to manage "Eth" records linked to "Pc" ones.
> >
> > On the "pc" backend module, I've configured the form to only show some
> > widgets (because pc inherits from Obj which many useless fields in the
> > context of a pc).
> >
> > This gives us this in generator.yml :
> >
> >      form:
> >        display: [id_type_obj, name, num_cmd, num_serie, date_liv,
> > date_ins, position, garantie, id_typeOrdi, id_site, id_modele,
> > puissance, thermique, bruit, microp, freq, mem, peripheriques_list,
> > users_list, new_Eth ]
> >
> > Works well until I add "Eth" in order to see existing "Eth" records
> > linked to existing "Pc"s.
> >
> > -> If the pc object already has an interface, it shows up
> > -> If not, I get an error 500 : "Widget "Eth" does not exist."
> >
> > Anyone an idea about how to deal with that ?
> >
> > Regards,
> >
> > Mikael
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> > To post to this group, send email to symfony-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> To post to this group, send email to symfony-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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