3 Replies Latest reply on Jul 19, 2007 7:02 PM by gniit

    Accordiion and FormItem binding

      Hi,

      I've created a form with the following code :

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" xmlns:domain="flex.domain.*"
      width="100%" height="100%" >

      <domain:contact id="contact"
      name="{name.text}"
      age="{age.text}" />

      <mx:Accordion id="accordion" height="70%" >

      <mx:Form width="100%" height="100%" label="General" backgroundColor="#e6e6e6" id="form" autoLayout="false">

      <mx:HBox height="26">
      <mx:FormItem label="Name">
      <mx:TextInput id="name" width="500" text="{contact.name}"/>
      </mx:FormItem>
      <mx:FormItem label="Age">
      <mx:TextInput id="age" text="{contact.age}"/>
      </mx:FormItem>
      </mx:HBox>

      </mx:Form>

      <mx:VBox label="Address">
      </mx:VBox>

      </mx:Accordion>

      </mx:Canvas>

      The problem is that the vaules in name and age are blank unless I use creationPolicy="all" in the accordion. Is there a way of loading the values without using creationPolicy="all".

      Thanks
        • 1. Re: Accordiion and FormItem binding
          bdeen
          gnitt,
          a little confused by this

          You have a model with id="contact" binding to the name and age textinput
          but you also have those textinput binding to the model.

          Maybe you should only bind one way, so set initial name="XYZ" age="0" on the model
          and then leave the bindings on the form items. I believe when the textinputs get update it should propagate that back to your domain object.
          • 2. Re: Accordiion and FormItem binding
            Level 1
            Hi,

            Having the form items id as same as contact attributes have worked fine for me, but as you suggest if you change the id's of the input to txtName and txtAge and bind name="{txtName.text}" and age="{txtAge.text}" the result is still the same.

            For reference have a look at this blog entry

            http://blog.digitalbackcountry.com/?p=314

            Here Ryan discusses the same issue that I'm facing.

            Thanks
            • 3. Re: Accordiion and FormItem binding
              Level 1
              Just to add to my previous posted code.

              There is a Data grid with Contacts. The user double clicks on a row which opens the form.

              var form:ContactForm = new ContactForm();
              form.contact = selectedContact;