Skip to content

Commit

Permalink
Merge pull request symfony2admingenerator#241 from Hakadel/master
Browse files Browse the repository at this point in the history
Add a required attribute for the "double_list" type in the template and fix a JS condition
  • Loading branch information
cedriclombardot committed Oct 10, 2012
2 parents 2ec5b45 + 5e02951 commit 3487377
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Resources/public/javascripts/double_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var sfDoubleList =
{
form = sfDoubleList.get_current_form(id);

callback = function() { sfDoubleList.submit(form, className) };
callback = function() { sfDoubleList.submit(form, className); };

if (form.addEventListener)
{
Expand Down Expand Up @@ -34,13 +34,15 @@ var sfDoubleList =
submit: function(form, className)
{
var element;
var selectedClassName;

for (var i = 0; i < form.elements.length; i++)
{
element = form.elements[i];
if (element.type == 'select-multiple')
{
if (element.className == className + '-selected')
selectedClassName = className + '-selected';
if (element.className.match(new RegExp(selectedClassName, 'gi')))
{
for (var j = 0; j < element.options.length; j++)
{
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<div style="float: left">
<div class="double_list_label">{% trans from "Admingenerator" %}double_list.selected{% endtrans %}</div>
<select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][]" multiple="true" id="{{ form.get("id") }}_selected" class="double_list_select-selected">
<select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][]" multiple="true" id="{{ form.get("id") }}_selected" {% if (form.vars.required) %}required="required" {% endif %}class="double_list_select-selected">
{% for choice in choices %}
{% if choice is selectedchoice(value) %}
<option value="{{ choice.value }}">{{ choice.label }}</option>
Expand Down

0 comments on commit 3487377

Please sign in to comment.