doulongsha5478
2014-12-03 07:01
浏览 12
已采纳

如何在php类中定义或不定义子项

I get a POST data by this code.

$form->handleRequest($request);

if ($form->isValid()) {

Then I want to get a data.

$form->get('send')->isChecked();

If there is a 'send' submit button, it works well,however there is not it show this error.

Child "send" does not exist.

Then I have struggled to see if 'send' data is included $form or not.

like this

if ($form->get('send') !== null){

However it shows the same error.

How can I tell there is 'send' submit button in $form ??


There is 'send' button or 'draft' button depending on the situation.

I would like to tell which button is exist.

if ($form->get('send')->isChecked()){
} 
else if( $form->get('draft')->isChecked()){
}

but ,this code shows the error when access the button which is not exist.

图片转代码服务由CSDN问答提供 功能建议

我通过此代码获取POST数据。</ p>

  $  form-&gt; handleRequest($ request); 
 
if($ form-&gt; isValid()){
 </ code> </ pre> 
 
 

然后我想获取数据。 </ p>

 <代码> $形式 - &GT;获得( '发送') - &GT;器isChecked(); 
 </代码> </ PRE> 
 
 

如果 有一个'发送'提交按钮,它运行良好,但没有显示此错误。</ p>

 子“发送”不存在。
 </ code>  </ pre> 
 
 

然后我一直在努力查看“发送”数据是否包含在$ form中。</ p>

像这样</ p>

  if($ form-&gt; get('send')!== null){
 </ code> </ pre> 
 
 

但是它显示相同的错误。< / p>

如何判断$ form中有'send'emitue按钮?</ p>


有'发送'按钮 或者“草稿”按钮取决于具体情况。</ p>

我想知道哪个按钮存在。</ p>

  if($ form-  &gt; get('send') - &gt; isChecked()){
} 
else if($ form-&gt; get('draft') - &gt; isChecked()){
} 
 </ code  > </ PRE> 
 
 

b ut,此代码显示访问不存在的按钮时的错误。</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题