2010-08-12 1 views
1

embedRelation의 프로토 타입은 ($ formArguments/$ formargs로 전달 된) 'options'배열에 대한 참조를 만듭니다.Symfony embedRelation 옵션 - 하위 양식 필드 가시성 설정

embedRelation("Model","ModelForm",$options_arr); 

options_arr이 관계에 대한 설정 등의 형태 검증기/위젯/포함

는 옵션은 어레이를 통과 할 수 있는가?

$formargs['something']['publish_date'] = new sfWidgetFormInputText(); 

또는 이와 같이 관계에 표시되는 양식 필드를 제한 할 수 있습니까?

sfFormDoctrine.class.php 에서
$formargs['something']['use_fields'] = array('publish_date'); 

...

* Embed a Doctrine_Collection relationship in to a form 
* 
*  [php] 
*  $userForm = new UserForm($user); 
*  $userForm->embedRelation('Groups AS groups'); 
* 
* @param string $relationName The name of the relation and an optional alias 
* @param string $formClass  The name of the form class to use 
* @param array $formArguments Arguments to pass to the constructor (related object will be shifted onto the front) 
* @param string $innerDecorator A HTML decorator for each embedded form 
* @param string $decorator  A HTML decorator for the main embedded form 
* 
* @throws InvalidArgumentException If the relationship is not a collection 
*/ 
public function embedRelation($relationName, $formClass = null, $formArgs = array(), $innerDecorator = null, $decorator = null) 

...

나는 $ formArgs 배열의 사양에 얻을 수 있었던 가장 가까운 곳()

* `title`: The title of the collection form once embedded. Defaults to the relation name. 
* `embedded_form_class`: The class name of the forms to embed. Uses the model name by default (a form based on a collection of Book objects embeds BookForm objects). 
* `collection_form_class`: Class of the collection form to return. Defaults to sfFormPropelCollection. 
* `hide_on_new`: If true, the relation form does not appear for new objects. Defaults to false. 
* `add_empty`: Whether to allow the user to add new objects to the collection. Defaults to true. 
* `add_delete`: Whether to add a delete widget for each object. Defaults to true. 
* `remove_fields`: The list of fields to remove from the embedded object forms 
* `item_pattern`: The pattern used to name each embedded form. Defaults to '%index%'. 

If `add_empty` is set to `true`, the following additional options are available: 

* `empty_label`: The label of the empty form. Defaults to 'new' + the relation name. 
* `add_link`: The text of the JavaScript link that displays the empty form. Defaults to `Ann new` 
* `max_additions`: The max number of additions accepted on the client side. Defaults to 0 (no limit) 

If `add_delete` is set to `true`, the following additional options are available: 

* `delete_name`: Name of the delete widget. Defaults to 'delete'. 
* `delete_widget`: Optional delete widget object. If left null, uses a `sfWidgetFormDelete` instance, which is a checkbox widget with a Javascript confirmation. 
* `alert_text`: The text of the Javascript alert to show. 
* `hide_parent`: Whether to hide the deleted form when clicking the checkbox. Defaults to true. 
* `parent_level`: The number of times parentNode must be called to reach the parent to hide. As a widget doesn't know if it's merged or embedded, this setting allows the JavaScript code used to hide the parent to find it. Recommended values: 6 for embedded form (default), 7 for merged form. 

어떤 통찰력이 크게 appr 것 : sfFormPropel.class.php에서이다 (I 교리 1.2을 사용하고 있습니다) eciated.

답변

1

나는 당신이 형식 인수로 array('toto' => 'pwet') 말을 넣어, 당신은 (위젯과 유효성 검사기 설정)

+0

@ user739436 다른 사용자의 답변을 편집하여 자신의 콘텐츠를 추가하지 마십시오. 주석 인 경우 주석을 추가하거나 예제 코드가 변경된 경우 변경 사항을 제안하십시오. –

+0

@ the Tin Man : 응? 다른 곳에 게시 하시겠습니까? – greg0ire

+0

아니요, 사용자의 739436 님의 답변에 댓글이 있어야 할 보류중인 수정이있었습니다. –

0

을 다 할 수 있습니다에서 $this->getOption('toto');를 사용하여 양식 'pwet'을 검색 할 수 있다고 생각 왜 안 다른 방법으로 이동 :

$o = $this->isNew() ? new Model() : $this->getObject()->getModel(); 
$model_form = new ModelForm($o); 

//now configure widgets and validators 
$model_form->setWidget('publish_date', new sfWidgetFormInputText()); 
$model_form->useFields(array('publish_date')); 

$this->embedForm('Model', $model_form);