<?
$item = $this->item;
$roles = $item['Roles'];
$title = 'User Custom Fields';
$title = $this->_($title);
$this->headTitle($title, 'SET');
$this->textDelay('breadcrumbText', $title);
?>

<div class="row">
        <div class="span10">
            <div class="slate">
             <ul class="nav nav-tabs">
                <li>
                <a href="<?=$this->uri('/admin/user/' . $item['id'])?>">Edit User</a>
                </li>
                <li class="active"><a href="<?=$this->uri('/admin/user/field/userfield/' . $item['id'])?>"><?=$this->_('User Fields')?></a></li>
                <li><a href="#"><?=$this->_('User Tags')?></a></li>
            </ul>
            </div>
        </div><!--span10 end-->

<?foreach($roles as $role):?>
<?
$form = new User\Form\UserFieldsForm();
$form
->useSubformGroup()
->addSubForm('UserRoleFields', new User\Form\UserRoleFieldsForm(null, $role['id']))
->setMethod('put')
->setView($this)
->setAction($this->uri('/admin/user/field/userfield/'))
->bind($item)
->prepare();
?>
    <form <?=$this->formAttr($form)?>>
        <?=$form->restful();?>
        <?=$form->helper('id')?>
        <input type="hidden" name="role_id" value="<?=$role['id']?>" />
        <div class="span10">
            <div class="slate">
                <div class="page-header">
                    <h2><?=$this->_('User Custom Fields')?></h2>
                </div>
                <fieldset class="form-horizontal">
                    <?if($subForm = $form->get('CommonFields')):?>
                    <?foreach($subForm->getMergeElements() as $element):?>
                    <div class="control-group <?=$subForm->isError($element['name']) ? 'error' : '';?>">
                        <?=$subForm->helper($element['name'], 'label', array('class' => 'control-label'))?>
                        <div class="controls">
                            <?=$subForm->helper($element['name'], 'form' . ucfirst($element['type']), array('class' => ''))?>        
                            <div class="help-block"><?=$subForm->helper($element['name'], 'formElementErrors')?></div>
                        </div>
                    </div>
                    <?endforeach?>
                    <?endif?>
                </fieldset>
                <div class="page-headr">
                    <h3><?=$role['roleName']?></h3>
                </div>
                <?$form = $form->get('UserRoleFields')?>
                <fieldset class="form-horizontal">
                    <?foreach($form->getMergeElements() as $element):?>
                    <div class="control-group <?=$form->isError($element['name']) ? 'error' : '';?>">
                        <?=$form->helper($element['name'], 'label', array('class' => 'control-label'))?>
                        <div class="controls">
                            <?=$form->helper($element['name'], 'form' . ucfirst($element['type']), array('class' => ''))?>        
                            <div class="help-block"><?=$form->helper($element['name'], 'formElementErrors')?></div>
                        </div>
                    </div>
                    <?endforeach?>
                </fieldset>
            </div>
        </div><!--span10 end-->

        <div class="span10 listing-buttons">
            <button id="save-publish" class="btn btn-success btn-large"><?=$this->_('Save')?></button>
        </div>
    </form>
<?endforeach?>

</div>
