Możesz także użyć #containerelementu formularza i kodu podobnego do następującego:
$wrapper = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('class-name'),
),
);
$wrapper['twitter-icon'] => array(
'#type' => 'markup',
'#markup' => '<div class="twitter-icon"></div>'
);
$wrapper['twitter-link'] => array(
'#type' => 'markup',
'#markup' => l(t('follow us on Twitter'), 'https://twitter.com/#!/zujava'),
);
Element #container otacza swoje elementy potomne <div>znacznikiem, którego klasa CSS jest klasą przekazaną we #attributeswłaściwości.
Możesz nawet użyć kontenera dla elementu „twitter-icon”, ale to nie daje żadnych korzyści, z wyjątkiem przypadku, gdy możesz dodać element do tego, jak w przypadku następującego kodu:
$wrapper = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('class-name'),
),
);
$wrapper['twitter-icon'] => array(
'#type' => 'container',
'#attributes' => array(
'class' => array('twitter-icon'),
),
);
if ($condition) {
$wrapper['twitter-icon']['twitter-icon-text'] => array(
'#type' => 'markup',
'#markup' => t('Icon text'),
);
}
$wrapper['twitter-link'] => array(
'#type' => 'markup',
'#markup' => l(t('follow us on Twitter'), 'https://twitter.com/#!/zujava'),
);