<?php $row_id = $this->view->survey_tag.'_row_'.$index; ?>
<?php $input_id = $this->view->survey_tag.'_answer_'.$index; ?>

<div class="form-group margin-top-20 margin-bottom-20 <?php echo $item['grid']; ?>" id="<?php echo $row_id; ?>">
	<label class="label-main-question"><?php echo $item['question']; ?></label>
	
	<input type="hidden" name="data[<?php echo $index; ?>][group]" value="<?php echo $group; ?>">
	
	<input type="hidden" name="data[<?php echo $index; ?>][type]" value="<?php echo $type; ?>">
	<input type="hidden" name="data[<?php echo $index; ?>][question]" value="<?php echo $item['question']; ?>">
	
	<?php switch($type): case 'radio': ?>
				<?php case 'checkbox': ?>
			
			<input type="hidden" name="data[<?php echo $index; ?>][answer][value]" value="<?php echo isset($item['default']) ? $item['default'] : ''; ?>">
	
			<?php foreach($item['answer'] as $answer_index => $answer): ?>
			
				<div class="form-check form-check-inline">
					
					<?php $checked = isset($item['default'])&&($answer['value']==$item['default']) ? 'checked' : ''; ?>
					
					<input class="form-check-input <?php echo $input_id; ?> <?php echo isset($item['extra_class']) ? $item['extra_class'] : ''; ?>" type="<?php echo $type; ?>" id="id_<?php echo $input_id; ?>_<?php echo $answer_index; ?>" name="data[<?php echo $index; ?>][answer][value]" value="<?php echo $answer['value']; ?>" <?php echo $checked; ?> <?php echo isset($item['extra']) ? $item['extra'] : ''; ?>>
					<label class="form-check-label" for="id_<?php echo $input_id; ?>"><?php echo $answer['label']; ?></label>
				</div>
			<?php endforeach; ?>
	
		<?php break;?>
		
		<?php case 'textarea': ?>
			
			<textarea name="data[<?php echo $index; ?>][answer]" class="form-control <?php echo $input_id; ?> <?php echo isset($item['extra_class']) ? $item['extra_class'] : ''; ?>" rows="<?php echo (isset($item['rows'])&&(int)$item['rows']>1) ? $item['rows'] : 1; ?>" id="id_<?php echo $input_id; ?>" <?php echo isset($item['extra']) ? $item['extra'] : ''; ?>><?php echo isset($item['default']) ? $item['default'] : ''; ?></textarea>
			<?php if(isset($item['extra_text'])): ?>
				<p class="text-muted"><small><?php echo $item['extra_text']; ?></small></p>
			<?php endif; ?>
		<?php break; ?>
		
		<?php case 'inputlist': ?>
			<?php foreach($item['list'] as $item_list_index => $list_item): ?>
				<div class="margin-bottom-10 margin-left-10">
					
					<div><?php echo $list_item['label']; ?></div>
					<input type="hidden" name="data[<?php echo $index; ?>][list][<?php echo $item_list_index; ?>][label]" value="<?php echo $list_item['label']; ?>">
					
					<?php if($list_item['type'] == 'radio'): ?>
						
						<input type="hidden" name="data[<?php echo $index; ?>][list][<?php echo $item_list_index; ?>][answer]" value="">
					
						<?php foreach($list_item['answer'] as $value_radio_answer): ?>
							<div class="form-check form-check-inline">
								<input class="form-check-input <?php echo $list_item['class']; ?>" type="radio"  name="data[<?php echo $index; ?>][list][<?php echo $item_list_index; ?>][answer]" value="<?php echo $value_radio_answer['value']; ?>" <?php echo isset($list_item['extra']) ? $list_item['extra'] : ''; ?>>
								<label class="form-check-label"><?php echo $value_radio_answer['label']; ?></label>
							</div>
						<?php endforeach; ?>
						
					<?php elseif ($list_item['type'] == 'textarea'): ?>
						<textarea name="data[<?php echo $index; ?>][list][<?php echo $item_list_index; ?>][answer]" class="form-control <?php echo $list_item['class']; ?>" <?php echo $list_item['extra']; ?> rows="<?php echo (isset($list_item['rows'])&&(int)$list_item['rows']>1) ? $list_item['rows'] : 1; ?>"></textarea>
					<?php else: ?>
						<input type="<?php echo $list_item['type']; ?>" name="data[<?php echo $index; ?>][list][<?php echo $item_list_index; ?>][answer]" class="form-control <?php echo $list_item['class']; ?>" <?php echo $list_item['extra']; ?>>
					<?php endif; ?>
				</div>
			<?php endforeach; ?>
		<?php break;?>
		
		<?php case 'file': ?>
			<?php if (isset($item['number']) && (int)$item['number']>0): ?>
				<?php for($i=1; $i<=$item['number']; $i++): ?>
					<?php $col = isset($item['file_grid'][$i-1]) ? $item['file_grid'][$i-1] : 'col-lg-12'; ?>
					<?php echo $this->partial('Survey/input-file', ['input_id'=>$input_id.'_'.$i, 'col'=>$col, 'extra_class'=>isset($item['extra_class']) ? $item['extra_class'] : '', 'required'=>isset($item['required']) ? $item['required'] : 0]); ?>
				<?php endfor; ?>
				
				<?php if(isset($item['extra_text'])): ?>
					<p class="text-muted"><small><?php echo $item['extra_text']; ?></small></p>
				<?php endif; ?>
				
			<?php endif; ?>
		<?php break;?>
		
		<?php default: ?>
			<input type="<?php echo $type; ?>" value="<?php echo isset($item['default']) ? $item['default'] : ''; ?>" name="data[<?php echo $index; ?>][answer]" id="id_<?php echo $input_id; ?>" class="form-control <?php echo $input_id; ?> <?php echo isset($item['extra_class']) ? $item['extra_class'] : ''; ?>" <?php echo isset($item['extra']) ? $item['extra'] : ''; ?>>
			<?php if(isset($item['extra_text'])): ?>
				<p class="text-muted"><small><?php echo $item['extra_text']; ?></small></p>
			<?php endif; ?>
		
	<?php endswitch;?>
</div>