field-details.blade.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <b><code>{{ $name }}</code></b>&nbsp;&nbsp;@if($type)<small>{{ $type }}</small>@endif @if(!$required)
  2. <i>optional</i>@endif &nbsp;
  3. @if(($isInput ?? true) && empty($hasChildren))
  4. @php
  5. $isList = Str::endsWith($type, '[]');
  6. $isPassword = preg_match('/password/', $name);
  7. $fullName = str_replace('[]', '.0', $name);
  8. $baseType = $isList ? substr($type, 0, -2) : $type;
  9. // Ignore the first '[]': the frontend will take care of it
  10. while (\Str::endsWith($baseType, '[]')) {
  11. $fullName .= '.0';
  12. $baseType = substr($baseType, 0, -2);
  13. }
  14. switch($baseType) {
  15. case 'number':
  16. case 'integer':
  17. $inputType = 'number';
  18. break;
  19. case 'file':
  20. $inputType = 'file';
  21. break;
  22. default:
  23. $inputType = 'text';
  24. }
  25. @endphp
  26. @if($type === 'boolean')
  27. <label data-endpoint="{{ $endpointId }}" hidden><input type="radio" name="{{ $fullName }}" value="{{$component === 'body' ? 'true' : 1}}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif><code>true</code></label>
  28. <label data-endpoint="{{ $endpointId }}" hidden><input type="radio" name="{{ $fullName }}" value="{{$component === 'body' ? 'false' : 0}}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif><code>false</code></label>
  29. @elseif($isList)
  30. <input type="{{ $isPassword ? 'password' : $inputType }}" name="{{ $fullName.".0" }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif hidden>
  31. <input type="{{ $isPassword ? 'password' : $inputType }}" name="{{ $fullName.".1" }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" hidden>
  32. @else
  33. <input type="{{ $isPassword ? 'password' : $inputType }}" name="{{ $fullName }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif hidden>
  34. @endif
  35. @endif
  36. <br>
  37. {!! $description !!}