我有一个非常奇怪的问题。使用我的开发环境(Ubuntu Guest上共享Windows主机)时,以下代码可以正常工作。但是,当在linux服务器上,或者即使我将文件复制到Ubuntu Guest但本机方向(未从主机共享)时,代码也会失败。我收到的错误是:
Zend\Form\FormElementManager::get was unable to fetch or create an instance for RA\Restriction\Form\ValueFieldset
因此,问题在于它永远无法找到该文件。堆栈跟踪死于
/vendor/zendframework/zendframework/library/Zend/ServiceManager/AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager->get('RA...', true)
这是我的表单文件的样子
namespace RA\Restriction\Form;
use Zend\Form\Form;
use Zend\Form\Element;
use Zend\InputFilter\InputFilter;
class RestrictionValueForm extends Form
{
public function __construct($name = null)
{
// we want to ignore the name passed
parent::__construct('attribute');
$this->setAttribute('method', 'post')
->setInputFilter(new InputFilter());;
$this->add(array(
'name' => 'restriction_id',
'attributes' => array(
'type' => 'hidden',
'id' => 'restriction_id',
),
));
$this->add(array(
'type' => 'collection',
'name' => 'value_name',
'options' => array(
'count' => 2,
'should_create_template' => true,
'template_placeholder' => '__placeholder__',
'label' => '',
'target_element' => array(
'type' => 'RA\Restriction\Form\ValueFieldset',
),
),
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'class' => 'btn btn-primary mar-right5',
'value' => 'Save',
'id' => 'submitbutton',
),
));
$this->add(array(
'name' => 'cancel',
'attributes' => array(
'type' => 'button',
'class' => 'btn',
'value' => 'Cancel',
'id' => 'cancel',
),
));
}
}
我整天都在努力,还没有想出一个解决方案,我什至建立了几个额外的环境,并确保配置相同。任何建议将不胜感激。
我终于能够解决问题。似乎在某些环境中,它不喜欢该字段集位于子目录中。我能够将我的字段集移动到/ RA / src / RA / Form / ValueFieldset,现在一切都很好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句