0
votes

I get an error in the above code,

Error: Child elements of 'FormItem' serving as the default property value for 'mxmlContentFactory' must be contiguous.

<s:Form id="bxPrePaidTypeAdvanced" width="100%">
    <s:layout>
    <s:VerticalLayout paddingTop="0" paddingLeft="0" paddingRight="0" paddingBottom="0"/>
    </s:layout>

    <s:FormItem width="0" label="Form Item:">
    <s:Label text="label text" />
    <s:layout>
    <s:HorizontalLayout paddingLeft="{(-1)*(rbPerDay.width + 16)}" gap="16"/>   
    </s:layout>

    <mx:RadioButton groupName="prePaidAdvanced"
id="rbPerDay"
label="{resourceManager.getString('locale','perDay')}"
labelPlacement="left"
change="rbPerDay_changeHandler(event)"/>

<mx:ComboBox id="cbDueDay" width="80" dataProvider="{daysArray}"/>
</s:FormItem>

Im migrating flex 3 to 4 so i dont know if i need to make some changes here.

And another thing, when i try to change <mx:RadioButton to <s:RadioButton the following error appear Cannot Resolve Attribute "labelPlacement" for component type spark.component.RadioButton

1
I don't think you're supposed to change the default layout of Form (which is FormLayout). I bet that's the cause of your error. As for the other error: as the error states, that attribute does not exist.RIAstar
so how can i change the padding? if not with <s:layout>?user1921386
You can use the layout property allright, but give it a FormLayout instead of a VerticalLayout.RIAstar
I tried but the error continues. <s:layout> <s:FormLayout paddingLeft="{(-1)*(rbPerDay.width + 16)}" gap="16"/> </s:layout>user1921386
Judging by the attributes you used, it looks like you replaced the layout of your FormItem, not the layout of your Form. FormItem can accept other layouts, but I suppose it will mess up the rendering. The default layout of FormItem is FormItemLayout.RIAstar

1 Answers

0
votes

Layouts and all other formatting stuff aside, the problem here is that you are mixing the mxml object's default value (a property which will vary from component to component) with other properties. Every mxml component has a default property. Default properties don't require you to prefix the object with the property name, like you do when setting the layout.

Let's break apart the child objects of your <s:FormItem />:

  • First child is a display object, a <s:Label /> -- because this label just appears as a child of the form item, it's using the default property which is called "mxmlContentFactory".

  • Second child is a <s:layout> property. This tag is telling the <s:FormItem /> to set it's layout property ... in this case to a <s:HorizontalLayout />. Using a non default layout is probably fine here, it's definitely not the cause of your error message.

  • Third child is another display object, a <s:RadioButton />. This child is supposed to be part of that default property (mxmlContentFactory) that the 1st child is using.

Your error message states that the items that are meant to be used for the "default property" should be contiguous. So by setting the layout property in the middle of two "default" properties, you create this error.

The solution is simple: move any property declarations (like <s:layout>) to either the beginning or end of the form item tag so they don't interfere with the values used by the "default property":

<s:FormItem width="0" label="Form Item:">
    <s:layout>
        <s:HorizontalLayout paddingLeft="{(-1)*(rbPerDay.width + 16)}" gap="16"/>   
    </s:layout>

    <s:Label text="label text" />
    <mx:RadioButton groupName="prePaidAdvanced" id="rbPerDay" label="{resourceManager.getString('locale','perDay')}" labelPlacement="left" change="rbPerDay_changeHandler(event)"/>

    <mx:ComboBox id="cbDueDay" width="80" dataProvider="{daysArray}"/>
<s:/FormItem>

This error would occur in Flex 3 or Flex 4. Again, it has nothing to do with the fact that you're trying to use a HorizontalLayout inside of your FormItem.