Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Multiform and conditional/dynamic fields

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 737 Views
  • rob.s
    Avatar
    Community Member
    78 Posts

    Multiform and conditional/dynamic fields Link to this post

    Hi,

    in my MultiForm Step i need fields dependend on the previous step.

    Example:
    Let's assume we have 2 DataObject classes:
    1. Category (has_many Article)
    2. Article (has_one Category)

    Step1 shows checkboxes of categories.
    Step 2 should bring up a checkboxfieldset of all Articles having the CategoryID selected in the first step.

    I thought i can access the form data inside the method getFields() in Step2

    function getFields() {
          $data = $this->loadData();
          Debug::dump($data);
    }

    but the debug output is an empty array.

    (I also checked the database: all selected CategoryIDs are save correctly. When using the previous button of MultiForm the checkboxes of the first step are also populated correctly)

    Any ideas ?

    Greetings,

    Rob

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: Multiform and conditional/dynamic fields Link to this post

    I created a workaround:

    function getFields() {

          $step = DataObject::get_one(
             'MultiFormStep',
             "SessionID ={$this->Session()->ID} AND ClassName='ProposalTemplateForm_Step1'"
          );
          if($step) {
             $data = $step->loadData();
          }
          ....

    }

    737 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.