- Posts: 61
- Thank you received: 3
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
- Topic Author
- Offline
- Senior Member
Less
More
3 years 2 months ago #210686
by alorenc
How to change the attributes in the beforeQuestionSave event? was created 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.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 2 months ago #210688
by DenisChenu
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.
Replied by DenisChenu on topic How to change the attributes in the beforeQuestionSave event?
Unclear …
What dropdown menu you want to update ?
If it's public : best is to use beforeQuestionRender
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.
The topic has been locked.
- alorenc
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
- Thank you received: 3
3 years 2 months ago - 3 years 2 months ago #210700
by alorenc
Replied by alorenc on topic How to change the attributes in the beforeQuestionSave event?
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?
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 2 months ago by alorenc.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 2 months ago #210702
by DenisChenu
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.
Replied by DenisChenu on topic How to change the attributes in the beforeQuestionSave event?
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)
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.
The topic has been locked.