2021-10-04 20:02:27 -07:00
< span > {{ -- This < span > doesn ' t seem to fix it , neither does a div ? -- }}
2021-06-28 22:40:18 -07:00
< div class = " form-group { { $errors->has ('custom_fieldset') ? ' has-error' : '' }} " >
2021-03-18 16:12:39 -07:00
< label for = " custom_fieldset " class = " col-md-3 control-label " > {{ trans ( 'admin/models/general.fieldset' ) }} </ label >
2021-09-30 16:21:23 -07:00
< span wire : ignore > {{ -- wire : ignore is because Select 2 mangles the dom in many awful ways , and so does iCheckbox -- }}
< div class = " col-md-9 " >
2021-10-04 20:02:27 -07:00
{{ Form :: select ( 'custom_fieldset' , Helper :: customFieldsetList (), old ( 'custom_fieldset' , $fieldset_id ), array ( 'class' => 'select2 js-fieldset-field' , 'style' => 'width:350px' , 'aria-label' => 'custom_fieldset' , 'wire:model' => 'fieldset_id' , 'id' => 'glooobits' )) }} {{ -- when we have this wrapped in 'ignore' , the wire : model won ' t work -- }}
2021-09-30 16:21:23 -07:00
{ !! $errors -> first ( 'custom_fieldset' , '<span class="alert-msg" aria-hidden="true"><br><i class="fas fa-times"></i> :message</span>' ) !! }
< label class = " m-l-xs " >
2021-10-04 20:02:27 -07:00
{{ Form :: checkbox ( 'add_default_values' , 1 , Request :: old ( 'add_default_values' , $add_default_values ), [ 'class' => 'minimal' , 'wire:model' => " add_default_values " , 'id' => 'add_default_values' ]) }}
2021-09-30 16:21:23 -07:00
{{ trans ( 'admin/models/general.add_default_values' ) }}
</ label >
</ span >
</ div >
2021-03-18 16:12:39 -07:00
</ div >
2021-11-15 21:09:35 -08:00
@ if ( $this -> add_default_values ) {{ -- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' -- }}
2021-03-18 16:12:39 -07:00
< div >
< div class = " form-group " >
2021-11-15 21:09:35 -08:00
@ if ( $fields )
2021-09-30 16:21:23 -07:00
@ foreach ( $fields as $field )
< div class = " form-group " >
< label class = " col-md-3 control-label { { $errors->has ( $field->name ) ? ' has-error' : '' }} " for = " default-value { { $field->id }} " > {{ $field -> name }} </ label >
< div class = " col-md-7 " >
2022-06-22 19:37:11 -07:00
@ if ( $field -> format == " DATE " )
< div class = " input-group col-md-4 " style = " padding-left: 0px; " >
< div class = " input-group date " data - provide = " datepicker " data - date - format = " yyyy-mm-dd " data - autoclose = " true " >
2022-06-22 19:47:08 -07:00
< input type = " text " class = " form-control " placeholder = " { { trans('general.select_date') }} " name = " default_values[ { { $field->id }}] " id = " default-value { { $field->id }} " value = " { { $field->defaultValue ( $model_id ) }} " >
2022-06-22 19:37:11 -07:00
< span class = " input-group-addon " >< i class = " fas fa-calendar " aria - hidden = " true " ></ i ></ span >
</ div >
</ div >
@ elseif ( $field -> element == " text " )
2021-09-30 16:21:23 -07:00
< input class = " form-control m-b-xs " type = " text " value = " { { $field->defaultValue ( $model_id ) }} " id = " default-value { { $field->id }} " name = " default_values[ { { $field->id }}] " >
@ elseif ( $field -> element == " textarea " )
2021-10-04 20:02:27 -07:00
< textarea class = " form-control " id = " default-value { { $field->id }} " name = " default_values[ { { $field->id }}] " > {{ $field -> defaultValue ( $model_id ) }} </ textarea >< br >
2021-09-30 16:21:23 -07:00
@ elseif ( $field -> element == " listbox " )
2021-10-04 20:02:27 -07:00
< select class = " form-control m-b-xs " name = " default_values[ { { $field->id }}] " >
2021-09-30 16:21:23 -07:00
< option value = " " ></ option >
2021-10-04 20:02:27 -07:00
@ foreach ( explode ( " \r \n " , $field -> field_values ) as $field_value )
< option value = " { { $field_value } } " {{ $field -> defaultValue ( $model_id ) == $field_value ? 'selected="selected"' : '' }} > {{ $field_value }} </ option >
2021-09-30 16:21:23 -07:00
@ endforeach
</ select >
2021-10-04 20:02:27 -07:00
@ elseif ( $field -> element == " radio " )
@ foreach ( explode ( " \r \n " , $field -> field_values ) as $field_value )
< input type = 'radio' name = " default_values[ { { $field->id }}] " value = " { { $field_value } } " {{ $field -> defaultValue ( $model_id ) == $field_value ? 'checked="checked"' : '' }} /> {{ $field_value }} < br />
@ endforeach
2021-09-30 16:21:23 -07:00
@ elseif ( $field -> element == " checkbox " )
2021-10-04 20:02:27 -07:00
< input type = 'checkbox' name = " default_values[ { { $field->id }}] " {{ $field -> defaultValue ( $model_id ) ? 'checked="checked"' : '' }} />
2021-09-30 16:21:23 -07:00
@ else
< span class = " help-block form-error " >
Unknown field element : {{ $field -> element }}
</ span >
@ endif
</ div >
</ div >
@ endforeach
2021-11-15 21:09:35 -08:00
@ endif
2021-09-30 16:21:23 -07:00
2021-03-18 16:12:39 -07:00
</ div >
</ div >
@ endif
2021-09-30 16:21:23 -07:00
< script >
2021-10-04 20:02:27 -07:00
// *still* haven't figured out why this doesn't seem to work at all...
// And even if it did, I hate having $(function () {}) as my DOM-ready checker in some places, and
// DOMContentLoaded in another...
/* document . addEventListener ( " DOMContentLoaded " , function () {
Livewire . hook ( 'component.initialized' , function ( component ) {
$ ( '#glooobits' ) . on ( 'select2:select' , function ( event ) { //'change' seems to be the jquery-compatible version but I think the select2 versions might be nicer.
console . log ( " Select2 has changed!!!!! " )
console . dir ( event )
@ this . set ( 'fieldset_id' , event . params . data . id )
// Livewire.first().set('fieldset_id',event.params.data.id) // I still don't know why @this does'nt work here?
})
})
}) */
2021-09-30 16:21:23 -07:00
</ script >
@ push ( 'js' )
< script >
$ ( function () {
$ ( '#glooobits' ) . on ( 'select2:select' , function ( event ) { //'change' seems to be the jquery-compatible version but I think the select2 versions might be nicer.
{{ -- @ this . set ( 'fieldset_id' , event . params . data . id ) -- }}
Livewire . first () . set ( 'fieldset_id' , event . params . data . id ) // I still don't know why @this does'nt work here?
})
$ ( '#add_default_values' ) . on ( 'ifToggled' , function ( event ) {
Livewire . first () . set ( 'add_default_values' , event . target . checked )
})
})
</ script >
@ endpush
2021-10-04 20:02:27 -07:00
</ span >