@@ -586,7 +586,6 @@ angular.module('schemaForm').provider('schemaForm',
586586 } ;
587587
588588 var fieldset = function ( name , schema , options ) {
589-
590589 if ( schema . type === 'object' ) {
591590 var f = stdFormObj ( name , schema , options ) ;
592591 f . type = 'fieldset' ;
@@ -640,7 +639,8 @@ angular.module('schemaForm').provider('schemaForm',
640639 path : arrPath ,
641640 required : required || false ,
642641 lookup : options . lookup ,
643- ignore : options . ignore
642+ ignore : options . ignore ,
643+ global : options . global
644644 } ) ] ;
645645
646646 return f ;
@@ -720,23 +720,27 @@ angular.module('schemaForm').provider('schemaForm',
720720
721721 var service = { } ;
722722
723- service . merge = function ( schema , form , ignore , options ) {
723+ service . merge = function ( schema , form , ignore , options , readonly ) {
724724 form = form || [ '*' ] ;
725725 options = options || { } ;
726726
727+ // Get readonly from root object
728+ readonly = readonly || schema . readonly || schema . readOnly ;
729+
727730 var stdForm = service . defaults ( schema , ignore , options ) ;
731+
728732 //simple case, we have a "*", just put the stdForm there
729733 var idx = form . indexOf ( '*' ) ;
730734 if ( idx !== - 1 ) {
731735 form = form . slice ( 0 , idx )
732736 . concat ( stdForm . form )
733737 . concat ( form . slice ( idx + 1 ) ) ;
734- return form ;
735738 }
736739
737740 //ok let's merge!
738741 //We look at the supplied form and extend it with schema standards
739742 var lookup = stdForm . lookup ;
743+
740744 return postProcessFn ( form . map ( function ( obj ) {
741745
742746 //handle the shortcut with just a name
@@ -767,26 +771,32 @@ angular.module('schemaForm').provider('schemaForm',
767771 } ) ;
768772 }
769773
774+ //extend with std form from schema.
775+
776+ if ( obj . key ) {
777+ var strid = sfPathProvider . stringify ( obj . key ) ;
778+ if ( lookup [ strid ] ) {
779+ obj = angular . extend ( lookup [ strid ] , obj ) ;
780+ }
781+ }
782+
783+ // Are we inheriting readonly?
784+ if ( readonly === true ) { // Inheriting false is not cool.
785+ obj . readonly = true ;
786+ }
787+
770788 //if it's a type with items, merge 'em!
771789 if ( obj . items ) {
772- obj . items = service . merge ( schema , obj . items , ignore ) ;
790+ obj . items = service . merge ( schema , obj . items , ignore , options , obj . readonly ) ;
773791 }
774792
775793 //if its has tabs, merge them also!
776794 if ( obj . tabs ) {
777795 angular . forEach ( obj . tabs , function ( tab ) {
778- tab . items = service . merge ( schema , tab . items , ignore ) ;
796+ tab . items = service . merge ( schema , tab . items , ignore , options , obj . readonly ) ;
779797 } ) ;
780798 }
781799
782- //extend with std form from schema.
783- if ( obj . key ) {
784- var str = sfPathProvider . stringify ( obj . key ) ;
785- if ( lookup [ str ] ) {
786- obj = angular . extend ( lookup [ str ] , obj ) ;
787- }
788- }
789-
790800 // Special case: checkbox
791801 // Since have to ternary state we need a default
792802 if ( obj . type === 'checkbox' && angular . isUndefined ( obj . schema [ 'default' ] ) ) {
@@ -984,8 +994,16 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf
984994 // section. Unless there is just one.
985995 var subForm = form . items [ 0 ] ;
986996 if ( form . items . length > 1 ) {
987- subForm = { type : 'section' , items : form . items } ;
997+ subForm = {
998+ type : 'section' ,
999+ items : form . items . map ( function ( item ) {
1000+ item . ngModelOptions = form . ngModelOptions ;
1001+ item . readonly = form . readonly ;
1002+ return item ;
1003+ } )
1004+ } ;
9881005 }
1006+
9891007 }
9901008
9911009 // We ceate copies of the form on demand, caching them for
0 commit comments