-
Notifications
You must be signed in to change notification settings - Fork 920
/
Copy pathform_content.blade.php
60 lines (56 loc) · 2.37 KB
/
form_content.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<form role="form">
{{-- Show the erros, if any --}}
@if ($errors->any())
<div class="callout callout-danger">
<h4>{{ trans('validation.please_fix') }}</h4>
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
{{-- Show the inputs --}}
@foreach ($crud['fields'] as $field)
<!-- load the view from the application if it exists, otherwise load the one in the package -->
@if(view()->exists('vendor.dick.crud.fields.'.$field['type']))
@include('vendor.dick.crud.fields.'.$field['type'], array('field' => $field))
@else
@include('crud::fields.'.$field['type'], array('field' => $field))
@endif
@endforeach
</form>
{{-- For each form type, load its assets, if needed --}}
{{-- But only once per field type (no need to include the same css/js files multiple times on the same page) --}}
<?php
$loaded_form_types_css = array();
$loaded_form_types_js = array();
?>
@section('after_styles')
<!-- FORM CONTENT CSS ASSETS -->
@foreach ($crud['fields'] as $field)
@if(!isset($loaded_form_types_css[$field['type']]) || $loaded_form_types_css[$field['type']]==false)
@if (View::exists('vendor.dick.crud.fields.assets.css.'.$field['type'], array('field' => $field)))
@include('vendor.dick.crud.fields.assets.css.'.$field['type'], array('field' => $field))
<?php $loaded_form_types_css[$field['type']] = true; ?>
@elseif (View::exists('crud::fields.assets.css.'.$field['type'], array('field' => $field)))
@include('crud::fields.assets.css.'.$field['type'], array('field' => $field))
<?php $loaded_form_types_css[$field['type']] = true; ?>
@endif
@endif
@endforeach
@endsection
@section('after_scripts')
<!-- FORM CONTENT JAVSCRIPT ASSETS -->
@foreach ($crud['fields'] as $field)
@if(!isset($loaded_form_types_js[$field['type']]) || $loaded_form_types_js[$field['type']]==false)
@if (View::exists('vendor.dick.crud.fields.assets.js.'.$field['type'], array('field' => $field)))
@include('vendor.dick.crud.fields.assets.js.'.$field['type'], array('field' => $field))
<?php $loaded_form_types_js[$field['type']] = true; ?>
@elseif (View::exists('crud::fields.assets.js.'.$field['type'], array('field' => $field)))
@include('crud::fields.assets.js.'.$field['type'], array('field' => $field))
<?php $loaded_form_types_js[$field['type']] = true; ?>
@endif
@endif
@endforeach
@endsection