]> git.agnieray.net Git - galette.git/commitdiff
Handle required fields when adding parent; refs #1362
authorJohan Cwiklinski <jcwiklinski@teclib.com>
Mon, 25 Nov 2019 21:47:55 +0000 (22:47 +0100)
committerJohan Cwiklinski <jcwiklinski@teclib.com>
Mon, 25 Nov 2019 21:47:55 +0000 (22:47 +0100)
galette/templates/default/member.tpl

index eb425dcb1cb6df16d905287ceb0678c162db6a2b..65882799e449aa2f2c51a3968489713d7aed4784 100644 (file)
                 });
     {/if}
 
-    {if !$self_adh and $member->hasParent()}
+    {if !$self_adh}
         {if $parent_fields|@count gt 0}
                 $('#detach_parent').on('change', function(){
                     var _checked = $(this).is(':checked');
                         $(_changes).removeAttr('required');
                     }
                 });
+
+                $('#parent_id').on('change', function(){
+                    var _hasParent = $(this).attr('value') != '';
+                    var _changes = '';
+            {foreach item=req from=$parent_fields}
+                    _changes += '#{$req}';
+                {if !$req@last}
+                    _changes += ',';
+                {/if}
+            {/foreach}
+                    if (_hasParent) {
+                        $(_changes).removeAttr('required');
+                    } else {
+                        $(_changes).attr('required', 'required');
+                    }
+                });
         {/if}
     {/if}
                 {include file="photo_dnd.tpl"}