File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
components/console/helpers Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,36 @@ You can also specify if you want to not trim the answer by setting it directly w
234234 $name = $helper->ask($input, $output, $question);
235235 }
236236
237+ Accept Multiline Answers
238+ ~~~~~~~~~~~~~~~~~~~~~~~~
239+
240+ .. versionadded :: 5.2
241+
242+ The ``setMultiline() `` and ``isMultiline() `` methods were introduced in
243+ Symfony 5.2.
244+
245+ By default, the question helper stops reading user input when it receives a newline
246+ character (i.e., when the user hits ``ENTER `` once). However, you may specify that
247+ the response to a question should allow multiline answers by passing ``true `` to
248+ :method: `Symfony\\ Component\\ Console\\ Question\\ Question::setMultiline `::
249+
250+ use Symfony\Component\Console\Question\Question;
251+
252+ // ...
253+ public function execute(InputInterface $input, OutputInterface $output)
254+ {
255+ // ...
256+ $helper = $this->getHelper('question');
257+
258+ $question = new Question('How do you solve world peace?');
259+ $question->setMultiline(true);
260+
261+ $answer = $helper->ask($input, $output, $question);
262+ }
263+
264+ Multiline questions stop reading user input after receiving an end-of-transmission
265+ control character (``Ctrl-D `` on Unix systems or ``Ctrl-Z `` on Windows).
266+
237267Hiding the User's Response
238268~~~~~~~~~~~~~~~~~~~~~~~~~~
239269
You can’t perform that action at this time.
0 commit comments