##### Nesting feature groups under features

It was mentioned in an earlier chapter that a <<feature-fk-init,feature may nest other features that reference it>>. [[fg-in-features]]It is also possible to nest a feature group under a feature with the condition that all the features included directly into the spec of the feature group reference the same parent feature.

For example, suppose we have a parent spec *featureP* and child spec *featureA* and *featureB*:

[source,xml]
----
 <feature-spec xmlns="urn:wildfly:pm-feature-spec:1.0" name="featureP">
   <params>
     <param name="parent" feature-id="true"/>
   </params>
 </feature-spec>
----

[source,xml]
----
 <feature-spec xmlns="urn:wildfly:pm-feature-spec:1.0" name="featureA">
   <refs>
     <ref feature="featureP"/>
   </refs>
   <params>
     <param name="parent" feature-id="true"/>
     <param name="a" feature-id="true"/>
   </params>
 </feature-spec>
----

[source,xml]
----
 <feature-spec xmlns="urn:wildfly:pm-feature-spec:1.0" name="featureB">
   <refs>
     <ref feature="featureP"/>
   </refs>
   <params>
     <param name="parent" feature-id="true"/>
     <param name="b" feature-id="true"/>
   </params>
 </feature-spec>
----

Now let's suppose that there is a group which consists of features of *featureA* and *featureB* specs.
[source,xml]
----
<feature-group-spec name="group1" xmlns="urn:wildfly:pm-feature-group:1.0">

  <feature spec="featureA">
    <param name="a" value="a1"/>
  </feature>
  <feature spec="featureB">
    <param name="id" value="b1"/>
  </feature>

</feature-group-spec>
----

This group can be nested under any instance of *featureP* and the *parent* parameters of the features in the group will implicitly be initialized to the value of the *parent* parameter of the outer *featureP* instance.
[source,xml]
----
<config>
  <feature spec="featureP">
    <param name="parent" value="p1"/>
    <feature-group name="group1"/>
  </feature>
  <feature spec="featureP">
    <param name="parent" value="p2"/>
    <feature-group name="group1"/>
  </feature>
</config>
----

The resulting config will include:

. _featureP:parent=p1_;

. _featureP:parent=p2_;

. _featureA:parent=p1,a=a1_;

. _featureA:parent=p2,a=a1_;

. _featureB:parent=p1,b=b1_;

. _featureB:parent=p2,b=b1_.

