2

how do you covert this html code into the yii CHtml?

<form aciton='site/qrcode' method='POST'>
<input type='text' value='Generate Code here..' name='generate' id='gen' onclick='checkval()' class='ext'>
<input type='submit' value='Generate' id='submit'>
</form>

can anyone please help? My main aim of this is to knkow how to put a class and Onclick event in a textbox or button.

1 Answer 1

3

Use the third parameter of the textField method (htmlOptions array), like this:

<?php echo CHtml::beginForm(); ?>

    <?php echo CHtml::textField('generate','Generate Code here...', array('id'=>'gen', 'onclick'=>'checkval()', 'class'=>'ext')) ?>

    <?php echo CHtml::submitButton('Generate', array('id'=>'submit')); ?>

<?php echo CHtml::endForm(); ?>

(I left all the opening and closing tags for other html to be interspersed.)

Sign up to request clarification or add additional context in comments.

2 Comments

thank you so much... this will help me a lot. but one more thing.... how do you specify the "aciton='site/qrcode' method='POST'" in the CHtml::beginForm() widget?
@ChUck_PrOg yiiframework.com/doc/api/1.1/CHtml#beginForm-detail, you should be able to figure out how to specify action and method, from that link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.