I want to have the layout at left but it appears the layout at right. Do you know why is not appearing in the select menu, input type text and textarea?
In the Question model there is this getHtmlInput
method() that is used in the view to generate the form fields:
In the registration.blade.php the questions are presented with the code below:
@if ($allParticipants == 0)
@foreach($selectedRtype['questions'] as $customQuestion)
<div class="form-group">
<label for="participant_question">{{$customQuestion->question}}</label>
@if($customQuestion->hasOptions())
{!! $customQuestion->getHtmlInput(
$customQuestion->name,
$customQuestion->options,
($customQuestion->pivot->required == '1'),
'form-control',
$customQuestion->type)
!!}
@endif
<input type="hidden"
name="participant_question_required[]"
value="{{ $customQuestion->pivot->required }}">
<input type="hidden"
value="{{ $customQuestion->id }}"
name="participant_question_id[]"/>
</div>
@endforeach
@endif
Generated html:
public function getHtmlInput($name = "", $options = "", $required = false, $class = "", $customtype=false)
{
$html = '';
$html .= $customtype == 'select' ? "<select name='$name' class='$class' ".($required?:" required").">" : '';
foreach($options as $option) {
switch ($customtype) {
case "text":
$html .= "
<div class='form-group'>
<input type='text' name='participant_question' class='form-control'". ($required?:" required") . ">".
' <label class="form-check-label" for="exampleCheck1">' . $option->value. '</label>'.
"</div>";
$html .= "<input type='text' name='participant_question' value='".$option->value."' class='form-control'" . ($required?:" required") . ">";
break;
case "checkbox":
$html .= "
<div class='form-check'>
<input type='checkbox' name='participant_question[]' value='".$option->value."' class='form-check-input'" . ($required?:" required") . ">".
' <label class="form-check-label" for="exampleCheck1">' . $option->value. '</label>'.
"</div>";
break;
case "radio_btn":
$html .= "
<div class='form-check'>
<input type='radio' name='participant_question[]' value='".$option->value."' class='form-check-input'" . ($required?:" required") . ">".
' <label class="form-check-label" for="exampleCheck1">' . $option->value. '</label>'.
"</div>";
break;
case "select_menu":
$html .= "<option value='".$option->value."'>";
break;
case "textarea":
$html .= "
<div class='form-group'>
<textarea name='participant_question' class='form-control' rows='3'" . ($required?:" required") . ">"
. $option->value .
"</textarea>
</div>";
break;
}
}
$html .= $customtype == 'select' ? "</select>" : '';
return $html;
}