request->get('showTopCancel', '0') === '1';
$renderCustomField = static function (string $fieldKey, AnimalProgressUpdateForm $formModel, array $definitions): string {
if (!isset($definitions[$fieldKey])) {
return '';
}
$definition = $definitions[$fieldKey];
$inputType = (string)$definition['input_type'];
$label = (string)$definition['label'];
if ((int)$definition['required'] === 1) {
$label .= ' *';
}
$fieldName = "AnimalProgressUpdateForm[customFields][$fieldKey]";
$fieldValue = $formModel->customFields[$fieldKey] ?? '';
ob_start();
?>
= Html::textarea($fieldName, (string)$fieldValue, ['class' => 'form-control', 'rows' => 3, 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::dropDownList(
$fieldName,
(string)$fieldValue,
$formModel->getCustomFieldSelectOptions($fieldKey),
['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalprogressupdateform-customfields-$fieldKey"]
) ?>
= Html::input('number', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'step' => 'any', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::input('date', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::input('datetime-local', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::textInput($fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
getCustomFieldDefinitions();
$knownProgressKeys = ['progress_notes', 'routine_updates', 'media_reference'];
$otherCustomDefinitions = [];
foreach ($customDefinitions as $fieldKey => $definition) {
if (in_array($fieldKey, $knownProgressKeys, true)) {
continue;
}
$otherCustomDefinitions[$fieldKey] = $definition;
}
$currentMediaReference = trim((string)($model->customFields['media_reference'] ?? ''));
$progressFormId = 'edit-progress-update-form';
$this->registerCss(<< .panel-heading {
color: #eef5fb;
background: rgba(10, 18, 28, 0.42);
border-color: rgba(255, 255, 255, 0.2);
}
.inline-editor-shell > .panel-body {
background: rgba(10, 18, 28, 0.2);
}
.inline-editor-shell .panel.panel-default {
border-color: rgba(255, 255, 255, 0.2);
background: rgba(10, 18, 28, 0.34);
}
.inline-editor-shell .panel.panel-default > .panel-heading {
color: #eef5fb;
background: rgba(10, 18, 28, 0.42);
border-color: rgba(255, 255, 255, 0.2);
}
.inline-editor-shell .panel.panel-default > .panel-heading a {
color: inherit;
display: block;
text-decoration: none;
}
.inline-editor-shell .panel.panel-default > .panel-heading a:hover,
.inline-editor-shell .panel.panel-default > .panel-heading a:focus {
color: #ffffff;
text-decoration: none;
}
.inline-editor-shell,
.inline-editor-shell .panel-body,
.inline-editor-shell .control-label,
.inline-editor-shell .checkbox label,
.inline-editor-shell .radio label,
.inline-editor-shell .help-block {
color: #eef5fb;
}
.inline-editor-shell .text-muted {
color: rgba(233, 242, 250, 0.78) !important;
}
.inline-editor-shell .form-control {
background: rgba(10, 18, 28, 0.56);
border-color: rgba(255, 255, 255, 0.44);
color: #f3f8ff;
}
.inline-editor-shell .form-control::placeholder {
color: rgba(243, 248, 255, 0.72);
}
.inline-editor-shell .form-control[readonly],
.inline-editor-shell .form-control[disabled] {
background: rgba(10, 18, 28, 0.42);
color: rgba(243, 248, 255, 0.72);
}
.inline-editor-shell select.form-control option {
color: #0f1b2a;
}
.inline-editor-shell .animal-inline-top-save-action {
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
padding: 0;
border-radius: 999px;
border: 1px solid rgba(255, 255, 255, 0.36);
background: rgba(15, 23, 42, 0.72);
color: #f8fafc;
cursor: pointer;
line-height: 1;
font-size: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.inline-editor-shell .animal-inline-top-save-action:hover,
.inline-editor-shell .animal-inline-top-save-action:focus {
background: rgba(30, 41, 59, 0.86);
border-color: rgba(255, 255, 255, 0.5);
color: #f8fafc;
outline: none;
}
CSS
);
if ($isInline) {
$this->registerCss(<< .panel:first-child {
margin-top: 0 !important;
}
CSS
);
}
?>
= Yii::t('AnimalManagementModule.base', 'Edit Progress Update') ?>
= Html::submitButton('', [
'class' => 'animal-inline-top-save-action',
'title' => Yii::t('AnimalManagementModule.base', 'Save Progress Update'),
'form' => $progressFormId,
]) ?>
= Html::button('', [
'id' => 'progress-inline-cancel-icon',
'class' => 'animal-inline-top-save-action',
'title' => Yii::t('AnimalManagementModule.base', 'Cancel'),
'type' => 'button',
]) ?>
$progressFormId, 'enctype' => 'multipart/form-data'];
if (!$isInline) {
$formOptions['target'] = '_top';
}
$form = ActiveForm::begin(['options' => $formOptions]);
?>
= Html::hiddenInput('returnTo', (string)($returnTo ?? 'view')) ?>
= $form->errorSummary($model, ['showAllErrors' => true]) ?>
= $form->field($model, 'weight') ?>
= $form->field($model, 'vitals')->textInput(['maxlength' => 255]) ?>
= $form->field($model, 'behavior_notes')->textarea(['rows' => 2]) ?>
= $form->field($model, 'medical_concerns')->textarea(['rows' => 2]) ?>
= $form->field($model, 'meal_plan_changes')->textarea(['rows' => 2]) ?>
= $form->field($model, 'housing_changes')->textarea(['rows' => 2]) ?>
= $renderCustomField('progress_notes', $model, $customDefinitions) ?>
= $renderCustomField('routine_updates', $model, $customDefinitions) ?>
$definition): ?>
= $renderCustomField($fieldKey, $model, $otherCustomDefinitions) ?>
= Yii::t('AnimalManagementModule.base', 'Social Post') ?>
= $form->field($model, 'post_to_space_feed')->checkbox() ?>
= $form->field($model, 'post_to_animal_feed')->checkbox() ?>
= Button::save(Yii::t('AnimalManagementModule.base', 'Save Progress Update'))->submit() ?>
= Button::asLink(Yii::t('AnimalManagementModule.base', 'Cancel'))
->link(($returnTo ?? 'view') === 'progress-updates'
? $space->createUrl('/animal_management/animals/progress-updates', ['id' => $animal->id])
: $space->createUrl('/animal_management/animals/view', ['id' => $animal->id])) ?>
registerCss(<<registerJs(<<');
} else {
preview.html('');
}
}
function markSelectedMediaThumb(value) {
$('.progress-media-select-thumb').removeClass('is-selected');
if (!value) {
return;
}
$('.progress-media-select-thumb').each(function() {
if (($(this).attr('data-media-url') || '') === value) {
$(this).addClass('is-selected');
}
});
}
$(document).off('click.editProgressMediaSelect', '.progress-media-select-thumb').on('click.editProgressMediaSelect', '.progress-media-select-thumb', function() {
var mediaUrl = $(this).attr('data-media-url') || '';
$('#progress-media-gallery-path').val(mediaUrl);
markSelectedMediaThumb(mediaUrl);
$('#progressMediaUpload').val('');
$('input[name="removeProgressMedia"]').prop('checked', false);
if (mediaUrl) {
renderProgressPreview(mediaUrl);
}
$('#progress-media-modal').modal('hide');
});
$(document).off('change.editProgressMediaUpload', '#progressMediaUpload').on('change.editProgressMediaUpload', '#progressMediaUpload', function() {
var file = this.files && this.files[0] ? this.files[0] : null;
if (!file) {
return;
}
$('#progress-media-gallery-path').val('');
markSelectedMediaThumb('');
$('input[name="removeProgressMedia"]').prop('checked', false);
var reader = new FileReader();
reader.onload = function(e) {
renderProgressPreview(e.target.result);
$('#progress-media-modal').modal('hide');
};
reader.readAsDataURL(file);
});
$(document).off('shown.bs.modal.editProgressMediaModal', '#progress-media-modal').on('shown.bs.modal.editProgressMediaModal', '#progress-media-modal', function() {
markSelectedMediaThumb($('#progress-media-gallery-path').val());
});
})();
JS
, \yii\web\View::POS_END);
if ($isInline) {
$cancelPayload = Json::htmlEncode([
'source' => 'animal-inline-editor',
'type' => 'cancel',
'collapseId' => 'progress-edit-inline-' . (int)$progressUpdate->id,
]);
$this->registerJs(<<