Reputation: 2305
I have a button using the following code in my view...
<?= Html::submitButton('Delete Summary', [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Really long message.<new line>Line 2<new line>Line 3?',
'method' => 'post',
],
]) ?>
I want to make the eventual confirmation dialog show my text on different lines, but none of the common notations such as \n
, <br>
, nor
work. I also tried putting \\n
instead of \n
, still it did not work.
How can I make the different parts of my confirmation show on a different line.
Upvotes: 1
Views: 1130
Reputation: 22154
You can use \n
is you define string using "
quotes:
<?= Html::submitButton('Delete Summary', [
'class' => 'btn btn-danger',
'data' => [
'confirm' => "Really long message.\nLine 2\nLine 3?",
'method' => 'post',
],
]) ?>
You can also split it into multiple lines to improve readability:
<?= Html::submitButton('Delete Summary', [
'class' => 'btn btn-danger',
'data' => [
'confirm' => "Really long message."
. "\nLine 2"
. "\nLine 3?",
'method' => 'post',
],
]) ?>
Upvotes: 1
Reputation: 133360
Just write as with the newline
<?= Html::submitButton('Delete Summary', [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Really long message.
Line 2
Line 3?',
'method' => 'post',
],
]) ;
?>
Upvotes: 0