폼의 레이블 위치를 변경하는 방법이 있습니까? 나는 입력 필드 (sfWidgetFormInputText 및 sfWidgetFormChoice) 위에 그것을 갖고 싶습니다. 그게 가능하니?Symfony 1.4 폼의 레이블 위치
0
A
답변
2
양식 필드를 어떻게 렌더링하는지에 따라 다릅니다. 당신이 당신의 형태로 나머지는 다르게 개별 필드를 렌더링 할 경우, 레이블을 렌더링하고 템플릿에서 다음과 같이 별도로 위젯을 할 수
:
// \apps\myApp\modules\myModule\templates\_form.php
echo $form['field_name']->renderLabel(); // Render the label
echo $form['field_name']->render(); // Render the widget
echo $form['field_name']->renderError(); // Render the error
echo $form['field_name']->renderHelp(); // Render the help message
경우에 당신은 그것을 몇 가지 방법을 수행 할 수 있습니다 전체 양식에 레이아웃을 적용하려고합니다. 당신은 새로운 포매터 클래스를 작성하고 양식에 적용해야합니다
// \lib\form\formatter\sfWidgetFormSchemaFormatterCustom.class.php
class sfWidgetFormSchemaFormatterCustom extends sfWidgetFormSchemaFormatter
{
protected
$rowFormat = '<div class="label">%label%</div><div class="field">%field%</div>%error% \n %help %hidden_fields%',
$errorRowFormat = '<div>%errors%</div>',
$helpFormat = '<div class="form_help">%help%</div>',
$decoratorFormat = '<div>\n %content%</div>';
}
이 같은 양식의 구성 방법에 적용 :
// \lib\form\myForm.class.php
public function configure()
{
//....
$formatter = new sfWidgetFormSchemaFormatterCustom($this->getWidgetSchema());
$this->widgetSchema->addFormFormatter('custom', $formatter);
$this->widgetSchema->setFormFormatterName('custom');
}
당신은 포맷이 프로젝트를 통해 전 세계적으로 사용하려면 ProjectConfiguration.class.php에서 기본 포맷터로 설정할 수 있습니다.
// \config\ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
// ...
sfWidgetFormSchema::setDefaultFormFormatterName('custom');
}
}
0
당신은 당신이 (... <td>
<th>
, <tr>
) html 태그를 사용하는 모든 양식을 재구성 할 수있는 형태와 관련된 template
에 그것을 할 수 있습니다.
관련 문제
- 1. Symfony 1.4 플러그인 작업
- 2. 업로드 파일 - symfony 1.4
- 3. Symfony 1.4 - format_currency API
- 4. help symfony 1.4
- 5. 계수가있는 symfony 1.4 모듈
- 6. validation in symfony 1.4
- 7. Symfony 1.4 폼 템플릿
- 8. Symfony 1.4 - sfCacheSessionStorage
- 9. 여러 개발자가있는 symfony 1.4
- 10. Symfony 1.4 및 angularJS
- 11. Symfony 1.4 Ajax
- 12. Symfony 1.4 https
- 13. 2-application Symfony 1.4 ROUTING
- 14. Symfony 1.4 대 Symfony 2.0의 혼동
- 15. Symfony 1.4 : propel과 fixtures에서 관계 사용
- 16. (symfony 1.4) 위젯에 옵션 추가
- 17. Symfony 1.4 embedRelation unset 필드
- 18. Symfony 1.4 doctrine create table
- 19. symfony 1.4 sf auth routing
- 20. symfony 1.4 기능 테스트 보고서
- 21. symfony 1.4 embedRelation where 절
- 22. symfony 1.4 - PHP 버전을 변경하십시오
- 23. NGINX + php-fpm + Symfony 1.4 = :(
- 24. symfony 1.4 : 문제 메서드 isDeleted()
- 25. Symfony 1.4 : attributeHolder를 조작하는 방법?
- 26. Symfony 1.4 FormValue after getValues ()
- 27. Symfony 1.4 sfWidgetFormInputFileEditable 맞춤 설정
- 28. Symfony 1.4 확장 모델 오류
- 29. Symfony 1.4 : 전자 메일 구성
- 30. 아파치의 userdir 아래 symfony 1.4
도움 주셔서 감사합니다. 새로운 포맷터 클래스를 만들었고 원하는대로 작동합니다. – alex