4
I have a form where I select colors for the page, and in it there is a checkbox with the option of usar padrão do site
, the moment I click on this checkbox it removes the field, but when I uncheck the checkbox
he should create the field again.
How would you do that?
<div class="form-group row">
{{ Form::label('metadata', 'Título', ['class' => 'col-sm-2 col-form-label']) }}
<div class="col-sm-10">
{{ Form::text('title', null, ['class' => 'form-control', 'placeholder' => 'Digite um Titulo','required' => true]) }}
</div>
</div>
<div class="form-group row">
{{ Form::label('metadata', 'Sub-título', ['class' => 'col-sm-2 col-form-label']) }}
<div class="col-sm-10">
{{ Form::text('subtitle', null, ['class' => 'form-control', 'placeholder' => 'Digite um Sub-Titulo']) }}
</div>
</div>
<div class="form-group row">
<label for="metadata" class="col-sm-2 col-form-label">Cor de fundo:</label>
<div class="col-sm-10">
<input name="" type="checkbox" value="background" onclick="enableColorsBackground(this.checked)"> Usar Padrão do
site
<input type="color" name="background" id="background">
</div>
</div>
<div class="form-group row">
{{ Form::label('metadata', 'Cor do título:', ['class' => 'col-sm-2 col-form-label']) }}
<div class="col-sm-6">
<input name="" type="checkbox" value="color-title" onclick="enableColorsTitle(this.checked)"> Usar Padrão do
site
<input type="color" name="color-title" id="color-title">
</div>
</div>
<script>
function enableColorsBackground() {
document.getElementById('background').remove() ;
}
function enableColorsTitle() {
document.getElementById('color-title').remove();
}
</script>
But the field can not go to the database, I was using Hidden, being that it hides, but send the field to the database. I really want to remove, but what I want is to create again, so I don’t know how it would be to do.
– Romulo Sousa
Look now.....
– Sam
Him as
disabled
works as removes?– Romulo Sousa
It is disabled, cannot be changed, but is still visible. The "None" display is hidden. If you do both, as I put it in the answer, it becomes invisible and is not sent to the back-end.
– Sam
Um, test here.
– Romulo Sousa