Edit Animal Profile') ?> New Animal Intake') ?>
['enctype' => 'multipart/form-data']]); ?> errorSummary($model, ['showAllErrors' => true]) ?> getCustomFieldDefinitions(); $galleryImageOptions = $model->getGalleryImageOptions(); $galleryImageUrls = array_keys($galleryImageOptions); $knownProfileFieldKeys = [ 'dob', 'age', 'rescue', 'lineage', 'backstory', 'previous_owner_user_id', 'previous_owner_name', 'previous_owner_business_name', 'previous_owner_street_address', 'previous_owner_city', 'previous_owner_state', 'previous_owner_zip', 'previous_owner_cell_phone', 'previous_owner_business_phone', 'previous_owner_email', ]; $renderCustomField = static function (string $fieldKey, AnimalForm $model, 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 = "AnimalForm[customFields][$fieldKey]"; $fieldValue = $model->customFields[$fieldKey] ?? ''; ob_start(); ?>
'form-control', 'rows' => 3, 'id' => "animalform-customfields-$fieldKey"]) ?>
getCustomFieldSelectOptions($fieldKey), ['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalform-customfields-$fieldKey"] ) ?>
'form-control', 'step' => 'any', 'id' => "animalform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalform-customfields-$fieldKey"]) ?>
getExistingCoverImagePath()): ?> <?= Yii::t('AnimalManagementModule.base', 'Cover Image') ?>
getExistingProfileImagePath()): ?> <?= Yii::t('AnimalManagementModule.base', 'Profile Image') ?>
field($model, 'coverImageGalleryPath')->hiddenInput()->label(false) ?> field($model, 'profileImageGalleryPath')->hiddenInput()->label(false) ?> field($model, 'coverImageFile')->fileInput(['accept' => 'image/*']) ?> field($model, 'profileImageFile')->fileInput(['accept' => 'image/*']) ?>
isFieldActive('name')) { echo $form->field($model, 'name')->textInput(['maxlength' => 190]); } ?>
isFieldActive('species')) { echo $form->field($model, 'species')->textInput(['maxlength' => 120]); } ?>
isFieldActive('breed')) { echo $form->field($model, 'breed')->textInput(['maxlength' => 120]); } ?>
isFieldActive('sex')) { echo $form->field($model, 'sex')->textInput(['maxlength' => 32]); } ?>
isFieldActive('status')) { echo $form->field($model, 'status')->dropDownList($model->getStatusOptions()); } ?>
isFieldActive('in_possession')) { echo $form->field($model, 'in_possession')->checkbox(); } ?>
isFieldActive('location_name')) { echo $form->field($model, 'location_name')->textInput(['maxlength' => 120]); } ?>
isFieldActive('city')) { echo $form->field($model, 'city')->textInput(['maxlength' => 120]); } ?>
isFieldActive('state')) { echo $form->field($model, 'state')->textInput(['maxlength' => 2]); } ?>
isFieldActive('zip')) { echo $form->field($model, 'zip')->textInput(['maxlength' => 10]); } ?>
isFieldActive('public_summary')): ?> field($model, 'public_summary')->textarea(['rows' => 4]) ?>
tileDisplayFields, DisplaySettingsForm::fieldOptions(), ['separator' => '
']) ?>
heroDisplayFields, DisplaySettingsForm::fieldOptions(), ['separator' => '
']) ?>
$definition) { if (in_array($fieldKey, $knownProfileFieldKeys, true)) { continue; } $remainingCustomFields[$fieldKey] = $definition; } ?>
$definition): ?>
submit() ?> link( !empty($isEdit) && $animal instanceof Animal ? $space->createUrl('/animal_management/animals/view', ['id' => $animal->id]) : $space->createUrl('/animal_management/animals/index') ) ?> createUrl('/animal_management/animals/delete', ['id' => $animal->id]), [ 'class' => 'btn btn-danger pull-right', 'style' => 'margin-left:8px;', 'data-method' => 'post', 'data-confirm' => Yii::t('AnimalManagementModule.base', 'Delete {name}? This will remove the animal record and local gallery uploads. This cannot be undone.', ['name' => $animal->getDisplayName()]), ] ) ?>
registerCss(<<registerJs(<<'; } return '
'; } function updatePreview(kind, value) { var previewId = kind === 'profile' ? '#animal-profile-preview' : '#animal-cover-preview'; if (value && (value.indexOf('/') === 0 || /^https?:\/\//i.test(value) || /^data:image\//i.test(value))) { $(previewId).html('' + kind + ' image' + ''); return; } $(previewId).html(renderPlaceholder(kind) + ''); } function markSelectedThumb(kind, value) { var modalId = kind === 'profile' ? '#animal-profile-image-manage-modal' : '#animal-cover-image-manage-modal'; $(modalId + ' .animal-image-select-thumb').removeClass('is-selected'); if (!value) { return; } $(modalId + ' .animal-image-select-thumb').each(function() { if ($(this).data('select-value') === value) { $(this).addClass('is-selected'); } }); } $(document).on('click', '.animal-image-select-thumb', function() { var kind = $(this).data('select-kind') || 'cover'; var target = $(this).data('select-target'); var value = $(this).data('select-value'); if (target && value !== undefined) { $(target).val(value); if (kind === 'profile') { $('#animalform-profileimagefile').val(''); $('#animalform-removeprofileimage').prop('checked', false); } else { $('#animalform-coverimagefile').val(''); $('#animalform-removecoverimage').prop('checked', false); } updatePreview(kind, value); markSelectedThumb(kind, value); if (kind === 'profile') { $('#animal-profile-upload-file-name').text(''); } else { $('#animal-cover-upload-file-name').text(''); } } $(this).closest('.modal').modal('hide'); }); $('#animal-cover-upload-trigger').on('click', function() { $('#animalform-coverimagefile').trigger('click'); }); $('#animal-profile-upload-trigger').on('click', function() { $('#animalform-profileimagefile').trigger('click'); }); $('#animalform-coverimagefile').on('change', function() { var file = this.files && this.files[0] ? this.files[0] : null; $('#animalform-coverimagegallerypath').val(''); $('#animalform-removecoverimage').prop('checked', false); if (!file) { return; } var reader = new FileReader(); reader.onload = function(e) { updatePreview('cover', e.target.result); markSelectedThumb('cover', ''); }; reader.readAsDataURL(file); $('#animal-cover-upload-file-name').text(file.name || ''); $('#animal-cover-image-manage-modal').modal('hide'); }); $('#animalform-profileimagefile').on('change', function() { var file = this.files && this.files[0] ? this.files[0] : null; $('#animalform-profileimagegallerypath').val(''); $('#animalform-removeprofileimage').prop('checked', false); if (!file) { return; } var reader = new FileReader(); reader.onload = function(e) { updatePreview('profile', e.target.result); markSelectedThumb('profile', ''); }; reader.readAsDataURL(file); $('#animal-profile-upload-file-name').text(file.name || ''); $('#animal-profile-image-manage-modal').modal('hide'); }); $('#animalform-removecoverimage').on('change', function() { if ($(this).is(':checked')) { $('#animalform-coverimagegallerypath').val(''); $('#animalform-coverimagefile').val(''); $('#animal-cover-upload-file-name').text(''); markSelectedThumb('cover', ''); updatePreview('cover', ''); } }); $('#animalform-removeprofileimage').on('change', function() { if ($(this).is(':checked')) { $('#animalform-profileimagegallerypath').val(''); $('#animalform-profileimagefile').val(''); $('#animal-profile-upload-file-name').text(''); markSelectedThumb('profile', ''); updatePreview('profile', ''); } }); $('#animal-cover-image-manage-modal').on('shown.bs.modal', function() { markSelectedThumb('cover', $('#animalform-coverimagegallerypath').val()); }); $('#animal-profile-image-manage-modal').on('shown.bs.modal', function() { markSelectedThumb('profile', $('#animalform-profileimagegallerypath').val()); }); })(); JS ); ?>