2017-03-23 1 views
1

form.title 필드를 숨기고 form.title 필드 값을 form.oro_eventname으로 설정하고 싶습니다.
사용자는 form.oro_eventname 만 볼 수 있지만 form.oro_eventname 값은 form.title으로 복사됩니다.필드 값을 다른 필드로 복사

아무에게도 어떻게 할 수 있습니까?

{% set dataBlocks = [{ 
    'title': 'General Information'|trans, 
    'class': 'active', 
    'subblocks': [ 
     { 
      'title': '', 
       'data': [ 
       form_row(form.title), 
       form_row(form.oro_eventname), 
       form_row(form.description), 
       form_row(form.backgroundColor), 
       form.calendarUid is defined ? form_row(form.calendarUid) : null, 
       form_row(form.attendees), 
       entity.recurrence is null ? form_row(form.reminders) : null, 
       form_row(form.notifyAttendees), 
       invitations.notify_attendees_component() 
      ] 
     }, 
     { 
      'title': '', 
      'data': [ 
       '<div ' ~ UI.renderPageComponentAttributes(calendarEventDateRange) ~ '>' ~ 
       form_row(form.start) ~ 
       form_row(form.end) ~ 
       form_row(form.allDay) ~ 
       '</div>', 
       form.recurrence is defined ? form_row(form.recurrence) : null 
      ] 
     } 
    ] 
}] %} 
+0

당신이하고 싶은 것이 무엇인지는 분명하지 않습니다. 더 자세한 정보를 제공하거나 필요한 사진을 제공 할 수 있습니까? –

답변

1

당신은 달성 할 수 있습니다 자바 스크립트

$title = $form->get('oro_eventname')->getData(); 
$yourEntity -> setTitle($title); 
+1

프런트 엔드 코드에 의존하지 않으려면 두 번째 방법을 권합니다. 일부 사용자는 일부 기기에서 광고를 피하기 위해 자바 스크립트를 사용 중지했습니다. –

+0

@MartinFasani 동의합니다. – mickdev

0

설정 제목 필드와 널 (NULL) 사실

$('#id_title').val() = $('#id_oro_eventname').val(); 

또는 컨트롤러 (예를 들어의 keyup 이벤트를 트리거하는 기능)와 엔티티 그래서, 양식에 제목 필드를 추가하지 않으면 null 값에 대한 유효성 검사 오류가 발생하지 않습니다.

/** 
* @var string 
* 
* @ORM\Column(name="title", type="string", length=30, nullable=true) 
*/ 
private $title; 

양식이 이와 같이 유효하면 추가/수정 작업 세트 제목 값에 포함하십시오.

if ($form->isValid()) { 
    $event = $form->getData(); 
    $event->setTitle($event->getOroEventname()); 

    // Other code like persist flush redirect... 
} 
관련 문제