<tr id="pollchoice-<?php echo $id ?>">
    <td class="cell-weight">
        <?php echo TbHtml::activeDropDownList($choice, "[$id]weight", $choice->weights); ?>
        <?php echo CHtml::error($choice, "[$id]weight"); ?>
    </td>
    <td class="cell-label">
        <?php echo TbHtml::activeTextField($choice, "[$id]label", array('size' => 60, 'maxlength' => 255)); ?>
        <?php echo CHtml::error($choice, "[$id]label"); ?>
        <div class="errorMessage display-none">You must enter a label.</div>
    </td>
    <td class="cell-actions">
        <?php
        $deleteJs = 'jQuery("#pollchoice-' . $id . '").find("td").fadeOut(1000,function(){jQuery(this).parent().remove();});return false;';

        if (isset($choice->id)) {
            // Add AJAX delete link
            echo CHtml::ajaxLink(
                    'Delete', array('/pollchoice/delete', 'id' => $choice->id, 'ajax' => TRUE), array('type' => 'POST', 'success' => 'js:function(){' . $deleteJs . '}'), array('confirm' => 'Are you sure you want to delete this item?', 'class' => 'btn btn-danger btn-sm')
            );
        } else {
            // Model hasn't been created yet, so just remove the DOM element
            echo CHtml::link('Delete', '#', array('onclick' => 'js:' . $deleteJs, 'class' => 'btn btn-danger btn-sm'));
        }
        // Add additional hidden fields
        echo CHtml::activeHiddenField($choice, "[$id]id");
        ?>
    </td>
</tr>
