Jump to content

Save input type text from FormBuilder to repeater field


BraseTheGreat
 Share

Recommended Posts

Hello,

I have this problem: I have a FormBuilder form, where is text input. The form is set to be save as Page with specific template. The template has a repeater field MemberIds. In Form there is a text field CommaSeparatedMemberIds. So user fill for example 123,456.789. And I need to store this three numbers in template repeater field. 

And I have no clue how to do this. 

One option is to store the value to some "help field" and use hook Page:added where I explode the string and save one by one to repeater field. But I think there is a better way. Is'n it?

Thank you for advice.

Link to comment
Share on other sites

Ok I did this:

Long story short I used POST value stored from Form. 

$wire->addHookAfter('Pages::added(template=contact)', function(HookEvent $event) {
    $page = $event->arguments(0);
   ...

    if($_POST["idtestone"]){
      $idtest = $page->zinzino_testids->getNew();
      $idtest->zinzino_testid = $_POST["idtestone"];
      $idtest->save();
      $page->zinzino_testids->add($idtest);  
    }

    $page->save();
    
  });

Better approach?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...