Example of hoauth form view for Yii Bootstrap extension - SleepWalker/hoauth GitHub Wiki
This is an example of hoauth/views/form.php
view for those, who use Yii Bootstrap extension:
<?php
/**
* @var HOAuthAction $this
* @var HUserInfoForm $form
*/
$form = $form->form;
Yii::import('bootstrap.form.*');
// redefine form classes
$form->buttonElementClass = 'TbFormButtonElement';
$form->inputElementClass = 'TbFormInputElement';
$form->activeForm = CMap::mergeArray(
$form->activeForm,
array(
'class'=>'bootstrap.widgets.TbActiveForm',
// your settings for TbActiveForm widget (e.g. type and other)
)
);
echo $form->renderBegin();
$elements='';
foreach($form->getElements() as $element)
$elements.= renderElement($element, $form);
echo "$elements\n";
$buttons = '';
foreach($form->getButtons() as $button)
$buttons.= renderElement($button, $form);
$buttons = $buttons!=='' ? '<div class="form-actions">'.$buttons.'</div>' : '';
echo "$buttons\n";
echo $form->renderEnd();
function renderElement($element, $form)
{
if(is_string($element))
{
if(($e=$form[$element])===null && ($e=$form->getButtons()->itemAt($element))===null)
return $element;
else
$element=$e;
}
if($element->getVisible())
{
if($element instanceof CFormInputElement)
{
if($element->type==='hidden')
return '<div class="hidden">'.$element->render().'</div>';
}
return $element->render();
}
return '';
}