Forum Academy Marketplace Showcase Pricing Features

Set multiline input via button

Hello guys!

I have comments system on my website and I would like to allow my users to quote other user comments.

To do that i would like to use BBCode so it would look like this:

[quote]User Comment[/qute]
User reply text.

For now i made it like this:

  1. I set initial value of multiline input as [quote]MultilineInput CustomState[/quote]
  2. Whenever User clicks button “reply” i change CustomState to current comment text value.

The problem is:
When user start typing something in multiline input and then click button “reply” nothing will happen because “Initial Value” is set up only once - on page load.

Can i somehow manipulate multiline input value (not initial value) with the usage of button?

Not sure if this is possible, but I have a plugin (free) named “Insert at caret position”. Try it and check if this work for your case.
I guess that the correct process in your case will be Trigger on Button click “Reply” with actions: Set focus on the multi input element and use Insert at caret position the content you want to add

I don’t understood :neutral_face:

Could you please give me a better explanation? Don’t quite understand the difficult to insert the previous comment between the BBcode after the reply…

@rpetribu maybe screenshots will help :slight_smile:

  1. Every comment have this “reply” button:

  2. When user clicks it, following BBCode is added to his Multiline Input:

  3. Final output is:

Every time user hits “reply” button “multiline input value” can be reset and set as bbcode mentioned above.

Can you help me with that now?

I will check your plugin @Jici but i also want to try do it native.

hummmmm, now I understood. There is an easy way to achive this final result with some changes…

What you will need is basically a hidden multiline input (let’s name it “hidden_multiline”).

  1. When you click a reply button you will store the text of the comment in a custom state named “comment_text”.

  2. You will write your reply in a multiline called “reply”.

  3. And when you submit your reply, what will be send is the value of your “hidden_multilne”, that sould be filled with something like this:

[BBcode]comment_tex’s value[/BBcode]

reply’s value

The downside of this method is that you will never see the comment you are replying in the same input you’re writing. But anyway, it is an easy way to achieve what you desire…

Thanks for your input but… The thing is i would like to let user see to what he is replying and being able to edit this quote (like on oldschool forums).

Aha!!! I made it… man, it was sooo simple… :sweat_smile:

  1. Link the “Initial Value” of your reply input with your custom state “comment_text”.

  2. Put the multiline reply field inside a group. Let’s call it “Group reply”.

  3. When you click the reply button you will need two actions in your workflow. FIRST, use the action to reset Group reply (this will reset your multiline to its original state) and SECOND use the action to store the comment’s value in yout custom state “comment_text”.

1 Like