field-details.blade.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. $fullName =str_replace('[]', '.0', $name);
  7. $baseType = $isList ? substr($type, 0, -2) : $type;
  8. // Ignore the first '[]': the frontend will take care of it
  9. while (\Str::endsWith($baseType, '[]')) {
  10. $fullName .= '.0';
  11. $baseType = substr($baseType, 0, -2);
  12. }
  13. switch($baseType) {
  14. case 'number':
  15. case 'integer':
  16. $inputType = 'number';
  17. break;
  18. case 'file':
  19. $inputType = 'file';
  20. break;
  21. default:
  22. $inputType = 'text';
  23. }
  24. @endphp
  25. @if($type === 'boolean')
  26. <label data-endpoint="{{ $endpointId }}" hidden>
  27. <input type="radio" name="{{ $fullName }}"
  28. value="{{$component === 'body' ? 'true' : 1}}"
  29. data-endpoint="{{ $endpointId }}"
  30. data-component="{{ $component }}" @if($required)required @endif
  31. >
  32. <code>true</code>
  33. </label>
  34. <label data-endpoint="{{ $endpointId }}" hidden>
  35. <input type="radio" name="{{ $fullName }}"
  36. value="{{$component === 'body' ? 'false' : 0}}"
  37. data-endpoint="{{ $endpointId }}"
  38. data-component="{{ $component }}" @if($required)required @endif
  39. >
  40. <code>false</code>
  41. </label>
  42. @elseif($isList)
  43. <input type="{{ $inputType }}"
  44. name="{{ $fullName.".0" }}"
  45. data-endpoint="{{ $endpointId }}"
  46. data-component="{{ $component }}" @if($required)required @endif hidden>
  47. <input type="{{ $inputType }}"
  48. name="{{ $fullName.".1" }}"
  49. data-endpoint="{{ $endpointId }}"
  50. data-component="{{ $component }}" hidden>
  51. @else
  52. <input type="{{ $inputType }}"
  53. name="{{ $fullName }}"
  54. data-endpoint="{{ $endpointId }}"
  55. data-component="{{ $component }}" @if($required)required @endif hidden>
  56. @endif
  57. @endif
  58. <br>
  59. {!! Parsedown::instance()->text($description) !!}