Welcome to the LimeSurvey Community Forum

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

Change List type Other text box to multirow?

More
6 years 8 months ago #193453 by blocka
I have a survey where "Other - please specify" text box would benefit from being multiple rows. Any way I can do this globally on a survey, for all Other specify form elements?
The topic has been locked.
More
6 years 8 months ago - 6 years 8 months ago #193499 by tpartner
You will need to change the text field from an <input /> to a <textarea />.

If you want it for specific questions:
- Create a custom question theme as described here - manualv4.limesurvey.org/Question_themes .
- Edit /upload/themes/question/yourQuestionThemeName/survey/questions/answer/listradio/rows/answer_row_other.twig.

If you want it for all list-radios you can override the core view in your survey theme:
- Extend your theme and copy /application/views/survey/questions/answer/listradio/ into /upload/themes/survey/customSurveyThemeName/views/survey/questions/answer/.
- Edit /upload/themes/survey/yourSurveyThemeName/views/survey/questions/answer/listradio/rows/answer_row_other.twig.

In either case, you want something like this in answer_row_other.twig:

Code:
{% set otherValue = answer_other|replace({'value="': ''})|trim('"', 'right')|trim %} <!-- answer_row_other --> <li id='javatbd{{ myfname }}' class='answer-item radio-text-item form-inline' role='group' {{ sDisplayStyle }} > <!-- Checkbox + label --> <div class="form-group othertext-label-checkox-container radio-item"> <input type="radio" value="-oth-" name="{{ name }}" id="SOTH{{ name }}" {{ checkedState }} /> <label for="SOTH{{ name }}" class="control-label label-radio" id="label-id-{{ name }}">{{ othertext }}</label> </div> <!-- comment --> <div class="form-group text-item other-text-item"> <textarea class="form-control {{ kpclass }}" name="{{ name }}other" id="answer{{ name }}othertext" title="{{ gT('Other') }}" aria-labelledby="label-id-{{ name }}" >{{ otherValue }}</textarea> </div> <script> $("#answer{{ name }}othertext").on("keyup",function(){ if($.trim($(this).val())!=''){ $('#SOTH{{ name }}').click(); }; }); </script> </li> <!-- end of answer_row_other -->

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 8 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
6 years 8 months ago #193510 by blocka
Perfect, thank you! I was able to do the same for multiple choice with other option, based on your guidance!
The topic has been locked.
Moderators: tpartner, holch

Lime-years ahead

Online-surveys for every purse and purpose