How to change the attributes in the beforeQuestionSave event?

More
10 months 2 weeks ago #210686 by alorenc
I wrote a plugin where I added a drop down menu based on the value selected, I would like to change the values of other attributes not present in the Question object only in QuestionAttribute.

But I don't want to call befoeQuestionAttriibuteSave because if the value of the given attribute is empty then the event for that attribute doesn't exist.

I would like to change $ _POST values somehow (or otherwise change it?) Or raise a write event for the changed attribute. Unfortunately, I don't know how to do this.

Please Log in to join the conversation.

More
10 months 2 weeks ago #210688 by DenisChenu
Unclear …

What dropdown menu you want to update ?

If it's public : best is to use beforeQuestionRender

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
10 months 2 weeks ago - 10 months 2 weeks ago #210700 by alorenc
I wrote a plugin. It adds a new attribute "newQuestionAttributes", that is "validation_type" of type "singleselect".

When editing the poll, edit the question. On the right side of the "Plugins" menu I have such a window with eg E-mail, Phone etc. I choose "Phone" and click save.

The plug-in catches the "beforeQuestionSave" event. In this case, I check this validation_type if it is "Phone". If so, he wants to set the appropriate validation rules in the 'em_validation_q' and 'em_validation_q_tip' fields.

The problem is that the "em_validation_q" fields are not present in the question attributes ($this->event->get('model')).

I don't know how to change the attribute for em_validation_q in such a way that it writes those attribute. Changing the value in $_POST doesn't change that.

How can I do it differently? How should it be correct. Is it possible in beforeQuestionSave event?
Last edit: 10 months 2 weeks ago by alorenc.

Please Log in to join the conversation.

More
10 months 2 weeks ago #210702 by DenisChenu
beforeQuestionSave : Question model
beforeQuestionAttributeSave : QuestionAttribute model

related feature request:
- bugs.limesurvey.org/view.php?id=15876
- bugs.limesurvey.org/view.php?id=13727 (the best one)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now