2011-10-26 11 views
7

मैं Symfony2 FOSUserBundle में पंजीकरणफॉर्म टाइप को ओवरराइड करने का प्रयास कर रहा हूं। मैं प्रलेखन का पालन कर रहा हूं और मानता हूं कि मैंने सब कुछ शामिल किया है। मैंने अपने ओवरराइड को FOSUserBundle में रखने के लिए एक बंडल बनाया है और निम्न कोड इस बंडल के साथ-साथ एप्लिकेशन कॉन्फ़िगरेशन से है।FOSUserBundle फ़ॉर्म प्रकारों को ओवरराइड करते समय "XYZ" त्रुटि लोड नहीं कर सका

क्या किसी ने FOSUserBundle को ओवरराइड करते समय इसका अनुभव किया है, या मेरे कोड में कुछ भी देख रहा है जो यह समझाने में मदद करेगा कि मुझे यह त्रुटि क्यों मिल रही है। मैं सिम्फोनी v2.0.4

RegistrationFormType.php

<?php 

/* 
* This file is part of the FOSUserBundle package. 
* 
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> 
* 
* For the full copyright and license information, please view the LICENSE 
* file that was distributed with this source code. 
*/ 

namespace Thrive\SaasBundle\Form\Type; 

use Symfony\Component\Form\FormBuilder; 
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType; 

class RegistrationFormType extends BaseType 
{ 

    public function buildForm(FormBuilder $builder, array $options) 
    { 
     $builder 
      ->add('firstname', null, array('error_bubbling' => true)) 
      ->add('lastname', null, array('error_bubbling' => true)) 
      ->add('company', null, array('error_bubbling' => true)) 
      ->add('email', 'email', array('error_bubbling' => true)) 
      ->add('username', null, array('error_bubbling' => true)) 
      ->add('plainPassword', 'repeated', array('type' => 'password', 'error_bubbling' => true)) 
      ; 
    } 

    public function getName() 
    { 
     return 'thrive_user_registration'; 
    } 

} 

Services.yml

services: 
    thrive_saas_registration.form.type: 
    class: Thrive\SaasBundle\Form\Type\RegistrationFormType 
    arguments: [%fos_user.model.user.class%] 
    tags: 
     - { name: form.type, alias: thrive_user_registration} 

आवेदन के कॉन्फ़िग फ़ाइल

fos_user: 
    ... 
    registration: 
     form: 
     type: thrive_user_registration 
+0

सेवा पैरामीटर में '% fos_user.model.user.class%' के बजाय इस पैरामीटर '% fos_user.model.user.form_data_class%' का उपयोग करने के बारे में कैसे? –

उत्तर

4

बाहर कर देता है मेरी services.yml फ़ाइल निर्भरता इंजेक्शन के माध्यम से लोड नहीं किया जा रहा था। चारों ओर खोदने के बाद मुझे एहसास हुआ कि इस बंडल के लिए मेरी extension.php फ़ाइल गलत तरीके से नामित की गई थी। प्रारंभिक रूप से मैंने बंडल का नाम बदल दिया था और निर्भरता इंजेक्शन फ़ोल्डर के अंदर extension.php फ़ाइल का नाम बदलते समय एक टाइपो बनाया था। गलत वर्तनी को सही करने के बाद सबकुछ फिर से काम करता है।

+0

बिल्कुल सही, मैं भी अपनी विस्तार फ़ाइल चूक गया। – jmoz

0

आप बस एक जोड़ने की कोशिश की थी पर हूँ नया क्षेत्र और देखो अगर यह काम करता है?

public function buildForm(FormBuilder $builder, array $options) 
{ 
    parent::buildForm($builder, $options); 

    // add your custom field 
    $builder->add('name'); 
} 

इसके अलावा, आप वहां से परीक्षण कर रहे हैं, तो आपके prod कैश को साफ़ करने के लिए याद ...

+0

मेरे पास है और यह मदद नहीं कर रहा था। मैंने Symfony \ Component \ Form \ AbstractType से विस्तार करने का भी प्रयास किया है; कन्स्ट्रक्टर में जोड़ने और getDefaultOptions तर्क कि FOS 'पंजीकरणFormType का उपयोग करता है। यह या तो इसे ठीक नहीं लग रहा था। – Jeremy

+0

यह बहुत अजीब लग रहा है। यदि यह मेरे साथ होता है तो मैं FOSUserBundle के रूप में "जैसा है" के दस्तावेज़ों का पालन करने का प्रयास करता हूं, फिर आवश्यक कॉन्फ़िगरेशन के लिए छोटे बदलावों के साथ जाएं ... – dlondero

+0

हाँ, यह अजीब है ... मैं अपना कोड वापस रोल करने की कोशिश करने जा रहा हूं और फिर से बंडल को लागू करें जिसमें मेरे एफओएस अनुकूलन हैं। – Jeremy

संबंधित मुद्दे