chcę tylko przesłać do kontrolera wybraną w selekcie wartość. A on mi waliduje jakoś dziwacznie po kliknięciu submit buttona. Co jest nie tak z klasą NrKlientaType?
(IMG:
http://i60.tinypic.com/14t3u6e.jpg)
(IMG:
http://i61.tinypic.com/m7xdld.jpg)
(IMG:
http://i60.tinypic.com/28u4s51.jpg)
1.kawałek kontrolera
$NrKlientaForm = $this->createForm(new NrKlientaType());
2. class NrKlientaTyp
class NrKlientaType extends AbstractType {
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm
(FormBuilderInterface
$builder, array $options) { $builder
->add('idklient', 'entity', array( 'class' => 'AppBundle:Klient',
'placeholder' => 'Nr klienta',
'label' => false,
'property' => 'idklient',
))
->add('filtruj', 'submit');
;
}
//
// /**
// * @param OptionsResolverInterface $resolver
// */
// public function setDefaultOptions(OptionsResolverInterface $resolver) {
// $resolver->setDefaults(array(
// 'data_class' => 'AppBundle\Entity\Klient'
// ));
// }
/**
* @return string
*/
public function getName() {
return 'idklient';
}
}
3. kawałek entity Klient
/**
* @var string
*
* @Assert\Length(
* min = 6,
* max = 6,
* exactMessage = "Kod pocztowy powinien składać się z {{ limit }} znaków w formacie CC-CCC",
* )
*
* @ORM\Column(name="kodPocztowy", type="string", length=6, nullable=true)
*/
private $kodpocztowy;
Ten post edytował twojastara 3.09.2015, 21:40:50