smarty의 html_options 함수의 경우 smarty를 사용하지 않는 것 이외에는이 작업을 수행하지 않아도되는 방법이 있습니까?Smarty html_options
{if $smarty.post}
{html_options name=option_1 options=$options selected=$smarty.post.option_1}
{else}
{html_options name=option_1 options=$options}
{/if}
내가 템플릿에 표시되지 않습니다 것을 깨닫게하지만 템플릿에 정의되어 있지 않은 무언가를 떠날 나쁜 관행처럼 보인다 은 (또한 정의되지 않은 인덱스에 대한 잡음이 내 오류 로그를 채워).
내가 무엇을 찾고하는 것은 정의되지 않은 인덱스 오류가 표시 가진뿐만 아니라 템플릿 파일의 유식 소음을 감소하지 않고 이런 식으로 할 수있는 방법입니다
[편집].
{html_options name=option_1 options=$options selected=$smarty.post.option_1}
수정 된 html_options 플러그인 일 가능성이 높습니다. @의 mmcgrail의 생각으로 당
[편집]
: 그것은, 템플릿에 새 변수를 만드는 똑똑한의 예상 목표에서 벗어나고 있기 때문에
{if isset($smarty.post.option_1)}
{assign var=selected value=$smarty.post.option_1}
{else}
{assign var=selected value=$default.option_1}
{/if}
{html_options name=option_1 options=$options selected=$selected}
나는이 더 악화을 찾을 수 있습니다.
나 :
나는이 작품 추측{html_options name=option_1 options=$options selected=$option_1}
하지만 게시물의 모든 추적을 유지하는 똑똑한의 포인트는/무엇 :
<?php
//[... snip ...]
$option_1 = isset($_POST['option_1'])? $_POST['option_1'] : $default['option_1'];
$template->assign('option_1', $option_1);
$template->display('my_template.tpl');
그리고 템플릿 작성해야하는 코드의 양을 두 배로 늘리지 않고 템플릿에서 사용할 수 없다면/request/cookie/server/constant를 얻으시겠습니까?
한 행을 int로 넣을 때 발생하는 오류는 무엇입니까? – mcgrailm
post 변수가 비어있을 때 "NOTICE : Undefined index : option_1"이 표시됩니다. 끔찍한 끔찍한 오류는 아니지만 거기에 그대로 두는 것이 바람직하지 않다고 생각합니다. – SeanJA
또 다른 문제점은 html을 검사 할 때 선택 상자에 알림이 표시되지 않는다는 것입니다. – SeanJA