Php Laravel背包相关文本框
我被拉威尔的背包困住了 我想在单击复选框时显示文本框。我想在我的项目中实现这一点。如何使用控制器实现此功能? 我的字段在控制器中初始化 controller.phpPhp Laravel背包相关文本框,php,laravel-5.2,backpack-for-laravel,Php,Laravel 5.2,Backpack For Laravel,我被拉威尔的背包困住了 我想在单击复选框时显示文本框。我想在我的项目中实现这一点。如何使用控制器实现此功能? 我的字段在控制器中初始化 controller.php // ***** // FIELDS ALTERNATIVE // ***** "fields" => [ [ 'name' => "event_name", 'label' =&
// *****
// FIELDS ALTERNATIVE
// *****
"fields" => [
[
'name' => "event_name",
'label' => "Event name",
'type' => "text",
'placeholder' => "First Name and Last Name",
],
[
'name' => "event_topic",
'label' => "Event Topic",
'type' => "text",
'placeholder' => "Event Topic",
],
[
'name' => "event_type_id",
'label' => "Event Type",
'model' => "App\Larapen\Models\EventType",
'entity' => "eventType",
'attribute' => "name",
'type' => "select",
],
[ // Checkbox
'name' => 'social_links',
'label' => 'Links to facebook and twitter',
'type' => 'checkbox'
],
]
当我点击“社交链接”复选框时,我的添加页面中会显示两个文本框
请帮我解决这个问题。等待答复……。您可以这样做:
var checked=document.getElementById('checkbox');
选中。addEventListener('change',function(){
如果(选中此项){
document.getElementById('text_1').style.display='block';
document.getElementById('text_2').style.display='block';
}否则{
document.getElementById('text_1').style.display='none';
document.getElementById('text_2').style.display='none';
}
});代码>
文本区域1
文本区域2
您可以执行以下操作:
var checked=document.getElementById('checkbox');
选中。addEventListener('change',function(){
如果(选中此项){
document.getElementById('text_1').style.display='block';
document.getElementById('text_2').style.display='block';
}否则{
document.getElementById('text_1').style.display='none';
document.getElementById('text_2').style.display='none';
}
});代码>
文本区域1
文本区域2
我只是对马可提供的答案做了一点修改
[
'name' => 'social_links',
'label' => 'Links to facebook and twitter',
'type' => 'checkbox',
'id'=>'checkbox'
],
[
'name' => "event_name",
'label' => "Event name",
'type' => "text",
'placeholder' => "First Name and Last Name",
'id'=>'text_1',
],
[
'name' => "event_topic",
'label' => "Event Topic",
'type' => "text",
'placeholder' => "Event Topic",
'id'=>'text_2'
],
查看页面
<script>
$( document ).ready(function() {
$('#text_1').parent().hide();
$('#text_2').parent().hide();
});
var checked = document.getElementById('checkbox');
checked.addEventListener('change', function() {
if (this.checked){
$('#text_1').parent().show();
$('#text_2').parent().show();
} else {
$('#text_1').parent().hide();
$('#text_2').parent().hide();
}
});
</script>
$(文档).ready(函数(){
$('#text_1').parent().hide();
$('#text_2').parent().hide();
});
var checked=document.getElementById('checkbox');
选中。addEventListener('change',function(){
如果(选中此项){
$('#text_1').parent().show();
$('#text_2').parent().show();
}否则{
$('#text_1').parent().hide();
$('#text_2').parent().hide();
}
});
我只是对马可提供的答案做了一点修改
[
'name' => 'social_links',
'label' => 'Links to facebook and twitter',
'type' => 'checkbox',
'id'=>'checkbox'
],
[
'name' => "event_name",
'label' => "Event name",
'type' => "text",
'placeholder' => "First Name and Last Name",
'id'=>'text_1',
],
[
'name' => "event_topic",
'label' => "Event Topic",
'type' => "text",
'placeholder' => "Event Topic",
'id'=>'text_2'
],
查看页面
<script>
$( document ).ready(function() {
$('#text_1').parent().hide();
$('#text_2').parent().hide();
});
var checked = document.getElementById('checkbox');
checked.addEventListener('change', function() {
if (this.checked){
$('#text_1').parent().show();
$('#text_2').parent().show();
} else {
$('#text_1').parent().hide();
$('#text_2').parent().hide();
}
});
</script>
$(文档).ready(函数(){
$('#text_1').parent().hide();
$('#text_2').parent().hide();
});
var checked=document.getElementById('checkbox');
选中。addEventListener('change',function(){
如果(选中此项){
$('#text_1').parent().show();
$('#text_2').parent().show();
}否则{
$('#text_1').parent().hide();
$('#text_2').parent().hide();
}
});
当我在字段中添加属性时,helpers.php第531行显示error“ErrorException:htmlentities()期望参数1为字符串,数组给定(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crud\fields\text.blade.php)(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crud\fields\text.blade.php)(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crud\fields\text.blade.php)“您声明字段的方式可能有错误。我使用完整的backpack crud语法更新了代码在我的字段中添加属性时,会显示错误”ErrorException in helpers.php第531行:htmlentities()预期参数1为字符串,数组给定(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crud\fields\text.blade.php)(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crude\fields\text.blade.php)(视图:C:\wamp\www\Classified\resources\views\vendor\backpack\crud\fields\text.blade.php)您声明字段的方式可能有错误。我用完整的BACKBACK crud语法更新了代码