Skip to content

Commit

Permalink
Merge pull request #39 from Matteo-Peronnet/fix-editing-form-questions
Browse files Browse the repository at this point in the history
Fix editing form
  • Loading branch information
paulandrieux authored Jul 27, 2018
2 parents a90a008 + 8939068 commit f06b68f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Form/WidgetFormQuestionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'widget_form.form.question.alignment.left' => 'left',
'widget_form.form.question.alignment.right' => 'right',
],
'data' => 'full',
'choices_as_values' => true,
'expanded' => true,
'empty_data' => 'full',
]
);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/formCreator.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% endfilter %}
{% endspaceless %}</div>">
{% for question in form.questions %}
<li class="question" data-id="{{ loop.index0 }}">
<li class="question" data-id="{{ loop.index0 }}" style="overflow: hidden">
<div class="question-header">
<span class="question-link"><i class="fa fa-arrows fa-3"></i></span>
</div>
Expand Down
14 changes: 7 additions & 7 deletions Resources/views/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set widgetId = widget.id|default('null') %}

{% block form_static %}
<div id="picker-{{ form.mode.vars.data }}" class="vic-tab-pane vic-active">
<div id="picker-{{ form.mode.vars.data }}" class="vic-tab-pane vic-active" data-quantum='{{ quantum }}'>
{{ form_start(form, {'attr' : {'id' : 'victoire_widget_form' }}) }}
<div class="vic-row">
<div class="vic-col-md-4">
Expand Down Expand Up @@ -100,25 +100,25 @@
icon.closest( ".question" ).find( ".question-content" ).toggle();
});
});
var questionHolder = $vic('ul#questions-form-list');
var questionHolder{{ quantum }} = $vic('div[data-quantum="{{ quantum }}"].vic-tab-pane ul#questions-form-list');
var $addQuestionLink = $vic('<a href="#" class="add_question_link">{{ "widget_form.form.question.new.label"|trans|raw }}</a>');
var $newQuestionLinkLi = $vic('<li class="question-add"></li>').append($addQuestionLink);
var $newQuestionLinkLi{{ quantum }} = $vic('<li class="question-add"></li>').append($addQuestionLink);
var targetOnOff = {{ form.autoAnswer.vars.checked == 'on' ? "true" : "false" }};
$vic(document).ready(function() {
questionHolder.find('li.question').each(function() {
questionHolder{{ quantum }}.find('li.question').each(function() {
var id = $vic(this).data('id');
showQuestionForm(id);
addQuestionFormDeleteLink($vic(this));
$vic(this).find('.question-position').val($vic('li.question').index($vic(this)));
$vic(this).find('.selector-type').attr('onChange', 'showQuestionForm(this)');
});
questionHolder.append($newQuestionLinkLi);
questionHolder{{ quantum }}.append($newQuestionLinkLi{{ quantum }});
$addQuestionLink.on('click', function(e) {
e.preventDefault();
addQuestionForm(questionHolder, $newQuestionLinkLi);
addQuestionForm(questionHolder{{ quantum }}, $newQuestionLinkLi{{ quantum }});
});
});
Expand Down

0 comments on commit f06b68f

Please sign in to comment.