글수정시 첨부파일 required 오류

https://www.cosmosfarm.com/threads/document/56532

이미 문의했지만, 소스를 올리라고해서 올렸는데 아직 답변없으셔서 부득이하게 다시올립니다

글쓰기에서 첨부파일은 requrired로 설정하여 업로드하면

글수정시 첨부파일이 있는데 수정하기 최종버튼누르면 첨부파일은 필수항목입니다 라고 alert가 뜹니다.

첨부파일이 있는데 왜 alert가 뜨는걸까요? ㅠ

번거롭겠지만 답변부탁드립니다 ㅠ

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
  • 원래의 첨부파일 코드를 아래의 코드로 변경해보시겠어요? 

    		<!-- 첨부파일 시작 -->
    		<?php for($attached_index=1; $attached_index<=$board->meta->max_attached_count; $attached_index++):?>
    		<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> attach-<?php echo $attached_index?>">
    			<label class="attr-name" for="kboard-input-file<?php echo $attached_index?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php echo $attached_index?></label>
    			<div class="attr-value">
    				<?php if(isset($content->attach->{"file{$attached_index}"})):?><?php echo $content->attach->{"file{$attached_index}"}[1]?> - <a href="<?php echo $url->getDeleteURLWithAttach($content->uid, "file{$attached_index}")?>" onclick="return confirm('<?php echo __('Are you sure you want to delete?', 'kboard')?>');"><?php echo __('Delete file', 'kboard')?></a><?php endif?>
    				<input type="file" id="kboard-input-file<?php echo $attached_index?>" name="kboard_attach_file<?php echo $attached_index?>" <?php echo $content->attach->{"file{$attached_index}"}[1] ? '' : 'required';?>>
    				<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    			</div>
    		</div>
    		<?php endfor?>
    		<!-- 첨부파일 끝 -->

    고맙습니다.

  • 답변주셔서 감사합니다

    저소스를 어디다가 넣나요? 비슷한 소스가 많아서 감이 안오네요 ㅠㅠ

    <?php elseif($field['field_type'] == 'attach'):?>
    	<?php if($board->meta->max_attached_count > 0):?>
    		<!-- 첨부파일 시작 -->
    		<?php for($attached_index=1; $attached_index<=$board->meta->max_attached_count; $attached_index++):?>
    		<div class="kboard-attr-row <?php echo $content->attach->{"file{$attached_index}"}[1] ? '' : 'required';?>>
    			<label class="attr-name" for="kboard-input-file<?php echo $attached_index?>"><span class="field-name"><?php echo esc_html($field_name)?></span> <span class="attr-required-text">*</span></label>
    			<div class="attr-value">
    				<?php if(isset($content->attach->{"file{$attached_index}"})):?><?php echo $content->attach->{"file{$attached_index}"}[1]?> - <a href="<?php echo $url->getDeleteURLWithAttach($content->uid, "file{$attached_index}")?>" onclick="return confirm('<?php echo __('Are you sure you want to delete?', 'kboard')?>');"><?php echo __('Delete file', 'kboard')?></a><?php endif?>
    				<input type="file" class="required" id="kboard-input-file<?php echo $attached_index?>" name="kboard_attach_file<?php echo $attached_index?>">
                    <span class="filenotice">Attachment format is hwp, doc, pdf, docx!</span>
    				<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    			</div>
    		</div>
    		<?php endfor?>

    이게 맞나요?

  • 안녕하세요~^^

    아래 예시 코드처럼 첨부파일이 있을 때는 required를 출력하지 않고, 없을때만 출력하여

    글 수정 시 첨부파일이 있는 경우는 경고창 없이 저장되게 할 수 있습니다.

    <?php echo $content->attach->{"file{$attached_index}"}[1] ? '' : 'required';?>

    수정하셨던 위치에 적절히 입력하여 확인해보시겠어요?

    고맙습니다.

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요