在我的edit.html.twig中,我有:
{% form_theme edit_form 'MyBundle:Entity:form.html.twig' %}
{% set img_src = asset('120x100.jpg') %}
{{ dump(img_src) }}
{{ dump(entity) }}
{{ form_widget(edit_form, {'form_type': 'horizontal', 'img_src': img_src }) }}
Run Code Online (Sandbox Code Playgroud)
我有img_src和实体转储没有问题.
在form.html.twig我有:
{% extends 'MyBundle:Form:bootstrap.html.twig' %}
{% block _entity_field_widget %}
{{ dump(img_src) }}
{{ dump(entity) }}
{% set type = 'hidden' %}
{{ block('form_widget_simple') }}
{% endblock _channel_media_widget %}
Run Code Online (Sandbox Code Playgroud)
bootstrap.html.twig只是一个bootstraped*form_div_layout.html.twig*
在那个小部件中我没有img_src也没有实体.
任何想法如何获取小部件中的实体?它应该传递给窗体小部件还是有另一种方式?我究竟做错了什么?
HTML:
<div class="control-group">
<label for="some_id" class="control-label">Some ID</label>
<div class="controls">
<input type="text" id="some_id" name="some_id" class="span4"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
$(function() {
$('#some_id').select2({
allowClear: true,
placeholder: 'Some ID',
minimumInputLength: 2,
multiple: true,
data: [
{id: 1, text: 'some text'},
{id: 2, text: 'some other text'},
{id: 3, text: 'some more text'}
]
});
$('#some_id').select2('data', [
{'id':1,'text':'some text'}
]);
console.log($('#some_id').select2('val'));
});
Run Code Online (Sandbox Code Playgroud)
第一次加载时它会复制值,清除值后它不会从输入中清除它。此外,如果您添加一个项目(例如“更多文本”)然后将其删除,则不会将其从输入值中清除。有没有办法让它停止复制值?还有一件事 - 如何禁用添加已添加的项目?
是否可以取消 iCheck 对 ifToggled 的操作?我有未经检查的输入:
$('input').iCheck().on('ifToggled', function(e) {
if (confirm('Don\'t check?')) {
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
输入仍然会被检查(JSFiddle 简单示例)。有什么办法可以取消活动吗?
我在Symfony 2.1.3中使用MopaBootstrapBundle和Twig模板.此捆绑包具有base.html.twig模板,其中包含脚本块:
{% block foot_script %}
{# To only use a subset or add more js overwrite and copy paste this block
To speed up page loads save a copy of jQuery in your project and override this block to include the correct path
Otherwise the regeneration is done on every load in dev more with use_controller: true
#}
{% javascripts
'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-transition.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-modal.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-dropdown.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-scrollspy.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-tab.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-tooltip.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-popover.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-alert.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-button.js'
'@MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-collapse.js' …Run Code Online (Sandbox Code Playgroud) javascript ×2
twig ×2
block ×1
bundle ×1
duplicates ×1
forms ×1
icheck ×1
jquery ×1
symfony ×1
symfony-2.1 ×1
variables ×1