- Posts: 409
- Thank you received: 34
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?
- blocka
- Topic Author
- Offline
- Platinum Member
Less
More
4 years 1 month ago #193453
by blocka
Change List type Other text box to multirow? was created 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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10629
- Thank you received: 3696
4 years 1 month ago - 4 years 1 month ago #193499
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Change List type Other text box to multirow?
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:
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: 4 years 1 month ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- blocka
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 409
- Thank you received: 34
4 years 1 month ago #193510
by blocka
Replied by blocka on topic Change List type Other text box to multirow?
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.