yii CHtml submitButtion

AntiGMO picture AntiGMO · Oct 22, 2013 · Viewed 11k times · Source

I start learning yii and try to make some changes in others' code. I want to add the submitButton function into other button (Complete submission button)

          if ($page == $pageCount) {

            echo CHtml::submitButton("Save", array('class' => 'btn', 'name' => 'files', 'title' => 'Save the updates to these files'));

            ?>
            <form action="/dataset/submit" method="post" style="display:inline">
                <input type="hidden" name="file" value="file">
                <input type="submit" value="Complete submission" class="btn-green" title="Submit changes to file details."/>
            </form>
  1. I know the 'files' is all values need submit, but where is click action ?
  2. Which action is related to this button?

     echo CHtml::submitButton("Save", array('class' => 'btn', 'name' => 'files', 'title' => 'Save the updates to these files'));
    
  3. How can i add the Save button function into the Complete submission button ?

Answer

Developerium picture Developerium · Oct 22, 2013

You can set all sorts of html options for your button after label, as an array, like:

echo CHtml::submitButton('Submit' , array(
    'onclick' => 'yourFunction()',
    'id' => 'btnSubmit',
    .
    .
    .
));

http://www.yiiframework.com/doc/api/1.1/CHtml#submitButton-detail