Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to change the attributes in the beforeQuestionSave event?

  • alorenc
  • alorenc's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 10 months 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.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
3 years 10 months 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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • alorenc
  • alorenc's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 10 months ago - 3 years 10 months 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: 3 years 10 months ago by alorenc.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
3 years 10 months 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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose