Hello everyone,
I’ve searched a lot on this topic but I couldn’t find anything useful, I hope someone can help me here.
I have a form in my application that submits data using a standard CHtml submitButton. I need to ask confirmation from the user before submitting, and in particular the user must be careful about a couple of values in the form, so I wanted to include them in the confirmation message.
Some sample code:
<div class="row">
<?php echo $form->labelEx($model, 'taxA'); ?>
<?php echo $form->textField($model, 'taxA'); ?>
<?php echo $form->error($model, 'taxA'); ?>
<?php echo $form->labelEx($model, 'taxB'); ?>
<?php echo $form->textField($model, 'taxB'); ?>
<?php echo $form->error($model, 'taxB'); ?>
</div>
<?php $htmlOptions = array('id' => 'submitbutton',
'confirm'=>'Are you sure you want to save data with taxA X% and taxB Y%?');
echo CHtml::submitButton('Save the data',$htmlOptions); ?>
I would want the confirm message to have the values from the fields instead of X and Y. So if the user has written 4 and 25 for instance, it would display "Are you sure you want to save data with taxA 4% and taxB 25%?"
I thought there’s probably some way to add them with JavaScript but I’m not really sure how to. Any idea?
Thanks in advance