container.blade.php 868 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. @props([
  2. 'style' => 'horizontal',
  3. 'route' => null,
  4. 'method' => 'POST',
  5. 'model' => null,
  6. 'handler' => null,
  7. 'enctype' => false,
  8. ])
  9. @php
  10. $formAttributes = ['class' => 'form-' . e($style)];
  11. if ($route) {
  12. $formAttributes['action'] = e($route);
  13. }
  14. $formAttributes['method'] = $method === 'GET' ? 'GET' : 'POST';
  15. if ($handler) {
  16. $formAttributes['onsubmit'] = 'return ' . e($handler);
  17. }
  18. if ($enctype) {
  19. $formAttributes['enctype'] = 'multipart/form-data';
  20. }
  21. @endphp
  22. <form {!! implode(
  23. ' ',
  24. array_map(
  25. function ($key, $value) {
  26. return $key . '="' . $value . '"';
  27. },
  28. array_keys($formAttributes),
  29. $formAttributes,
  30. ),
  31. ) !!}>
  32. @if (!in_array($method, ['GET', 'POST']))
  33. @method($method)
  34. @endif
  35. @csrf
  36. {!! $slot !!}
  37. </form>