유효성 검사가 반응이없고 제출을 차단합니다. 누군가가 무엇이 누락되었거나 내가 뭘 잘못하고 있다고 말할 수 있습니까? 분명히 isValid 메서드가 호출 될 때 유효성 검사기는 유효성 검사를 차단합니다. 엔터티에서이 변수의 유효성은 다음과 같습니다. /** * @var 문자열 * @Assert \ NotBlank() */ private $ pGaWeeks;실체에서의 symfony 유효성 확인 : misssing 무엇입니까?
제출은 pGaWeeks 변수에 주어진 것을 차단하고 비워 두었을 때도 차단됩니다. 오류 메시지가 나타나지 않습니다. "@Assert \ NotBlank()"가 코드에서 제외되면 제출이 잘됩니다.
validation: { enabled: true, enable_annotations: true }
과 html.twig :
{% extends '::base.html.twig' %}
{% block body %}
{{ form_start(form, {attr: {novalidate: 'novalidate'}}) }}
{% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %}
<h1 style="margin-top:60px"><img src="{{ asset('public/images/icons/icon_data_gross.gif') }}"> Create a New Patient Dataset</h1>
<div role="tabpanel" class="tab-pane active" id="PatientInfo">
<div class="panel panel-default">
<div class="panel-body">
{% include 'DataLiveBundle:DataAPatient:form.html.twig' with {
'form':form, 'isNew': true } only %}
</div>
</div>
</div>
{{ form_row(form._token) }}
{{ form_end(form) }}
{% endblock %}
편집 :
나는 또한 DataHomeController.php
public function newAction(Request $request){
if(!$this->hasFuAccess() || !$this->isAdmin()){
throw new AccessDeniedException("You do not have permission to access");
}
$newrecord =array();
$dataA = new DataAPatient();
array_push($newrecord,$dataA);
$appendForm = $this->createNewForm($dataA);
$appendForm->handleRequest($request);
if($appendForm->isSubmitted()){//Save
if($appendForm->isValid()){
$tmp_pKpPatientid = $this->storeDataAPatient($dataA);
$records = $this->getStepByStepSearch($dataA);
return $this->render('GeneralCommonBundle:DataHome:show.html.twig', array(
'records'=> $records,
'isNew' => false,
'newrecord' => $newrecord
));
}
// }
}
return $this->render('DataLiveBundle:DataAPatient:new.html.twig', array(
'form' => $appendForm->createView(),
));
}
그리고 config.yaml에이 DataLiveBundle : DataAPatient : form.html.twig :
{% block body %}
<div class="row" style='margin-bottom: 5px'>
<div style='white-space: nowrap'>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pSnnid, 'SNN-ID (if known)', {'label_attr':{'style':'margin-top:3px'}})}}</div>
<div class='col-xs-2'>{{ form_widget(form.pSnnid, {'attr':{'style':'width:105px'}})}}</div>
</div>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pPlaceOfBirth, 'Place of birth', {'label_attr':{'style':'margin-top:3px' }})}}</div>
<div class='col-xs-2'>{{ form_widget(form.pPlaceOfBirth , {'attr': {'style':'width:200px' }})}}</div>
</div>
</div>
</div>
<div class="row" style='margin-bottom: 5px'>
<div style='white-space: nowrap'>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pDateOfBirth, 'Date of birth', {'label_attr':{'style':'margin-top:3px'}})}}</div>
<div class='col-xs-2'> {{ form_widget(form.pDateOfBirth, {'id': 'P_Date_of_birth','attr':{'style':'width:100px', }})}}</div>
</div>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pPatientNo, 'Patient ID/Nr. NEO', {'label_attr':{'style':'margin-top:5px'}})}}</div>
<div class='col-xs-2'>{{ form_widget(form.pPatientNo, {'attr':{'style':'width:105px' }})}}</div>
</div>
</div>
</div>
<div class="row" style='margin-bottom: 5px'>
<div style='white-space: nowrap'>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pGaWeeks, 'Gestational age', {'label_attr':{'style':'margin-top:3px'}})}}</div>
<div class='col-xs-2'> <div class="input-group">{{ form_widget(form.pGaWeeks, {'id': 'P_GA_weeks', 'attr':{'style':'width:45px'}})}}<div class="input-group-addon">w</div></div>
<div class="input-group">{{ form_widget(form.pGaDays, {'id': 'P_GA_days','attr':{'style':'width:45px' }})}}<div class="input-group-addon">d</div></div></div>
</div>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pBirthWeight, 'Birth weight', {'label_attr':{'style':'margin-top:3px'}})}}</div>
<div class='col-xs-2'><div class="input-group">{{ form_widget(form.pBirthWeight, {'attr':{'style':'width:60px'}})}}<div class="input-group-addon">g</div></div></div>
</div>
</div>
</div>
<div class="row" style='margin-bottom: 5px'>
<div style='white-space:nowrap'>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pSex, 'Sex/Gender', {'label_attr':{'style':'margin-top:3px'}})}}</div>
<div class='col-xs-2' style='margin-top: 5px'>{{ form_widget(form.pSex, {'attr':{'style':'text-indent:10px'}})}}</div>
</div>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pNumberOfInfants, 'No. of infants in birth', {'label_attr':{'style':'margin-top:5px'}})}}</div>
<div class='col-xs-2'>{{ form_widget(form.pNumberOfInfants, {'attr':{'style':'width:35px'}})}}</div>
</div>
</div>
</div>
<div class="row" style='margin-bottom: 5px'>
<div style='white-space: nowrap'>
<div class='col-xs-5'>
{#<div class='col-xs-5'>{{ form_label(form.pEpoStudy, 'Child in EPO study')}}</div>#}
{# <div class='col-xs-2'>{{ form_widget(form.pEpoStudy, {'attr':{'style':'text-indent:10px'}})}}</div>#}
</div>
<div class='col-xs-5'>
<div class='col-xs-5'>{{ form_label(form.pRank, 'Rank (if >1)', {'label_attr':{'style':'margin-top:5px'}})}}</div>
<div class='col-xs-2'>{{ form_widget(form.pRank, {'attr':{'style':'width:35px'}})}}</div>
<div style='padding-right: 80px; margin-top: 8px'> (A/B/C/D..)</div>
</div>
</div>
<div style= 'padding-left:40px ; margin-top:50px;'> (<font color=red>*</font> = input necessary)</div>
{% if isNew == true %}
<div class='col-xs-2'>{{ form_widget(form.submit_new, {'attr':{'style':'width:160px ; color:red; margin-left:900px'}})}}</div>
{% else %}
<div style="padding-left:1000px"> <a class='btn btn-default btnNext'><font color=red>Continue »</font></a></div>
{% endif %}
</div>
{% endblock %}
그리고 createNewForm에 대한 코드 :
private function storeDataAPatient($dataA){
if (!$dataA) {
throw $this->createNotFoundException('Unable to find DataEFu2 entity.');
}
$em = $this->getDoctrine()->getManager();
$session = $this->getRequest()->getSession();
$em->persist($dataA);
$em->flush();
$tmp_pKpPatientid= $dataA->getpKpPatientid();
}
storeDataAPatient :
private function storeDataAPatient($dataA){
if (!$dataA) {
throw $this->createNotFoundException('Unable to find DataEFu2 entity.');
}
$em = $this->getDoctrine()->getManager();
$session = $this->getRequest()->getSession();
$em->persist($dataA);
$em->flush();
$tmp_pKpPatientid= $dataA->getpKpPatientid();
}
당신이 DataLiveBundle'의 코드를 보여 주 시겠어요 코드 . 만약 당신이'dump ($ appendForm-> getData()); 'pGaWeeks '가 비어 있습니까? 오류를 렌더링하지 않았기 때문에 "pGaWeeks가 비어 있어서는 안됩니다."라고 표시됩니다. – baris1892
'storeDataAPatient'는 무엇을합니까? –
"pGaWeeks"는 항상 비어 있습니다. –