示例#1
0
<?php

use canis\helpers\Html;
echo Html::beginForm('', 'post', ['class' => 'ajax']);
echo Html::beginTag('div', ['class' => 'form']);
$model->confirm = 1;
echo Html::activeHiddenInput($model, 'confirm');
if (count($model->possibleTargets) === 1) {
    $label = $model->labels[$model->possibleTargets[0]];
    echo '<div class="confirm">Are you sure you want with ' . $label['long'] . '?</div>';
} else {
    $parts = [];
    $parts[] = 'the ' . $model->object->objectType->title->getSingular(false) . ' <em>' . $model->object->descriptor . '</em>';
    if ($model->hasRelationshipTargets()) {
        $parts[] = 'its relationship with the ' . $model->relationshipWith->objectType->title->getSingular(false) . ' <em>' . $model->relationshipWith->descriptor . '</em>';
    }
    echo '<div class="confirm">What would you like to do to ' . implode($parts, ' and ') . '?</div>';
    echo '<div class="btn-group" data-toggle="buttons">';
    $itemOptions = ['container' => false];
    foreach ($model->possibleTargets as $target) {
        $label = $model->labels[$target];
        $labelOptions = isset($label['options']) ? $label['options'] : [];
        if (!isset($labelOptions['class'])) {
            Html::addCssClass($labelOptions, 'btn btn-default');
        } else {
            Html::addCssClass($labelOptions, 'btn');
        }
        if ($model->target === $target) {
            Html::addCssClass($labelOptions, 'active');
        }
        $labelOptions['title'] = ucfirst(strip_tags($label['long']));