Skip to content

Commit 051caed

Browse files
committed
Merge branch '4.4'
* 4.4: [Console] allow the answer to not be trimmed
2 parents c9a6443 + 9253a0c commit 051caed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,34 @@ provide a callback function to dynamically generate suggestions::
214214
$filePath = $helper->ask($input, $output, $question);
215215
}
216216

217+
.. versionadded:: 4.3
218+
219+
The ``setAutocompleterCallback()`` method was introduced in Symfony 4.3.
220+
221+
Do not Trim the Answer
222+
~~~~~~~~~~~~~~~~~~~~~~
223+
224+
You can also specify if you want to not trim the answer by setting it directly with
225+
:method:`Symfony\\Component\\Console\\Question\\Question::setTrimmable`::
226+
227+
use Symfony\Component\Console\Question\Question;
228+
229+
// ...
230+
public function execute(InputInterface $input, OutputInterface $output)
231+
{
232+
// ...
233+
$helper = $this->getHelper('question');
234+
235+
$question = new Question('What is the name of the child?');
236+
$question->setTrimmable(false);
237+
// if the users inputs 'elsa ' it will not be trimmed and you will get 'elsa ' as value
238+
$name = $helper->ask($input, $output, $question);
239+
}
240+
241+
.. versionadded:: 4.4
242+
243+
The ``setTrimmable()`` method was introduced in Symfony 4.4.
244+
217245
Hiding the User's Response
218246
~~~~~~~~~~~~~~~~~~~~~~~~~~
219247

0 commit comments

Comments
 (0)