开发者

Flex FormItem layout in nested component

I have a fairly straightforward Flex layout question.

Is there anyway to get FormItem's contained within a nested container to follow the alignment of the FormItem's in in the parent form container?

For example:

<mx:Form>

  <mx:FormItem label="This is a long label" id="formItem1">
   <mx:HBox>
     <mx:TextInput />
   </mx:HBox>
  </mx:FormItem>

  <s:BorderContainer>
    <mx:FormItem label="ShrtLbl" id="formItem2">
     <mx:HBox>
       <mx:TextInput />
     </mx:HBox>
    </mx:FormItem>  
  </s:BorderContainer>

</mx:Form>

In this case I would like the label for both formItem1 and formItem2 to have to开发者_开发技巧 the same width which would be the case if defined as follows:

<mx:Form>

  <mx:FormItem label="This is a long label" id="formItem1">
   <mx:HBox>
     <mx:TextInput />
   </mx:HBox>
  </mx:FormItem>

   <mx:FormItem label="ShrtLbl" id="formItem2">
     <mx:HBox>
       <mx:TextInput />
     </mx:HBox>
   </mx:FormItem>  

</mx:Form>

Any thoughts?


The Spark Form Skin uses the spark.layouts.FormLayout to control the layout of its children.

From the FormLayout source:

The FormLayout class defines the default layout for Spark Form skins. FormLayout provides a vertical layout for the child FormItem containers in the Form.

If any of the child containers uses a FormItemLayout, FormLayout will align the ConstraintColumns of each child.

Therefore the Layout does not look at any nested children of the form.

I would recommend creating your own custom form layout to handle your case.

oops, I see you're using the mx:FormItem not the s:FormItem. I would recommend using the spark variants.

Furthermore, there is no need to have an mx:HBox (or s:HGroup) inside a FormItem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜