예제 #1
0
 /**
  * Creates the form of password reset
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Zend\Form\Form
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'password'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'configmpassword', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'password')))), 'input_filter' => array('password' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Password is required'))), array('name' => 'StringLength', 'options' => array('min' => 6, 'max' => 256, 'messages' => array('stringLengthTooShort' => 'Password must be atleast 6 characters'))))), 'configmpassword' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Confirm password is required'))), array('name' => 'Identical', 'options' => array('token' => 'password', 'messages' => array('notSame' => 'Password and confirm password are not matching.', 'missingToken' => 'Password and confirm password are not matching.'))))))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #2
0
 /**
  * 
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return Zend\Form\ElementInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'orderno', 'options' => array('label' => 'Order No.'), 'attributes' => array('class' => 'changeaddress', 'style' => 'width:200px; height:30px;')))), 'input_filter' => array('orderno' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Order No. is required'))))))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #3
0
 /**
  * Makes the form for user to restore forgotten password
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Zend\Form\Form
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'username', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'email')))), 'input_filter' => array('username' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'validators' => array(new Validator\EmailAddress())))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #4
0
 /**
  * @param array $spec
  * @return \Zend\Form\FormInterface
  */
 protected function buildForm(array $spec)
 {
     if (!$this->formFactory) {
         $this->formFactory = new Factory();
     }
     return $this->formFactory->create($spec);
 }
예제 #5
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config_authentification_form');
     $factory = new Factory();
     $form = $factory->createForm($config);
     return $form;
 }
예제 #6
0
 /**
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return Zend\Form\ElementInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'sellingprice', 'options' => array('label' => 'Selling price'), 'attributes' => array('class' => 'setgoaltxt', 'onchange' => 'assignprice(event,this.value);', 'onkeyup' => 'assignprice(this.value);', 'onkeypress' => 'return checknummsp(event,this.value);', 'onchange' => 'calculate();', 'onfocus' => 'checkprice(this.value);', 'onchange' => 'checkprice(this.value);', 'style' => 'width:100px; height:30px;')))), 'input_filter' => array('sellingprice' => array('required' => true))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #7
0
 /**
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return Zend\Form\ElementInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'qty', 'value' => 1, 'attributes' => array('onchange' => 'return calcurate(this.value);', 'onkeypress' => 'return checknummsp(event,this.value);', 'style' => 'width:50px; height:20px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'size', 'options' => array('label' => 'Size', 'value_options' => array()), 'attributes' => array('style' => 'width:50px; height:20px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Radio', 'name' => 'paypalchk', 'value' => 1, 'options' => array('label' => 'Payment method', 'value_options' => array('1' => 'PayPal', '2' => 'Credit Card')), 'attributes' => array())), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'price', 'attributes' => array('style' => 'width:50px; height:20px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'cemail', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'cfname', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'clname', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'street1', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'street2', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'city', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'zipcode', 'attributes' => array('style' => 'width:250px; height:25px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'state', 'options' => array('label' => 'State', 'value_options' => array()), 'attributes' => array('onchange' => 'getneighborhoodcities(this.value);', 'style' => 'width:100px; height:33px;')))), 'input_filter' => array('qty' => array('required' => true), 'paypalchk' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Payment Mode is required.'))))), 'price' => array('required' => true), 'cemail' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Email is required'))))), 'cfname' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'First Name is required'))))), 'clname' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Last Name is required'))))), 'street1' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Street is required'))))), 'city' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'City is required'))))), 'zipcode' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Zip code is required'))))), 'state' => array('required' => true))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #8
0
 /**
  * Makes the form of user registration
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Zend\Form\Form
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'public_name', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'Public name'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'username', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'Email Id'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'password'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'configmpassword', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'password'))), array('spec' => array('name' => 'send', 'attributes' => array('type' => 'submit', 'class' => 'accbutton', 'value' => 'Sign In Now')))), 'input_filter' => array('public_name' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Public name is required'))))), 'username' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Email Id is required'))), new Validator\EmailAddress(), $serviceLocator->get('ValidatorManager')->get('EmailNotInUse'))), 'password' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Password is required'))), array('name' => 'StringLength', 'options' => array('min' => 6, 'max' => 256, 'messages' => array('stringLengthTooShort' => 'Password must be atleast 6 characters'))))), 'configmpassword' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Confirm password is required'))), array('name' => 'Identical', 'options' => array('token' => 'password', 'messages' => array('notSame' => 'Password and confirm password are not matching.', 'missingToken' => 'Password and confirm password are not matching.'))))))));
     $form->setAttribute('method', 'post');
     return $form;
 }
예제 #9
0
 /**
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return Zend\Form\ElementInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'camptitle', 'options' => array('label' => 'Campaign title'), 'attributes' => array('class' => 'setgoaltxt', 'style' => 'width:450px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'description', 'options' => array('label' => 'Campaign description'), 'attributes' => array('class' => 'setgoaltxt', 'style' => 'width:450px; height:120px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'no_ofdays', 'options' => array('label' => 'Number of days', 'value_options' => array(3 => '3 Days', 7 => '7 Days', 10 => '10 Days', 14 => '14 Days', 21 => '21 Days')), 'attributes' => array('class' => 'setgoaltxt', 'style' => 'width:150px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'url', 'options' => array('label' => 'Url'), 'attributes' => array('class' => 'setgoaltxt', 'onblur' => 'uniqueurl(this.value);', 'style' => 'width:100px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Checkbox', 'name' => 'add_checkbox', 'options' => array('label' => ''), 'attributes' => array('onclick' => 'opendiv(this.id);'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Checkbox', 'name' => 'newcheckbx', 'options' => array('label' => ''), 'attributes' => array('onclick' => 'newdivaddr(this.id);'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'firstname', 'options' => array('label' => 'First name'), 'attributes' => array('onkeypress' => 'return checkcharonly(event);', 'class' => 'changeaddress', 'style' => 'width:180px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'lastname', 'options' => array('label' => 'First name'), 'attributes' => array('onkeypress' => 'return checkcharonly(event);', 'class' => 'changeaddress', 'style' => 'width:180px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'newaddress', 'options' => array('label' => 'Adress'), 'attributes' => array('class' => 'changepasstextbox'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'newcity', 'options' => array('label' => 'City'), 'attributes' => array('onkeypress' => 'return checkcharonly(event);', 'class' => 'changeaddress', 'style' => 'width:100px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'newstate', 'options' => array('label' => 'State', 'value_options' => array()), 'attributes' => array('onchange' => 'getneighborhoodcities(this.value);', 'class' => 'changeaddress', 'style' => 'width:100px; height:33px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'newzipcode', 'options' => array('label' => 'Zip code'), 'attributes' => array('onkeypress' => 'return checknummsp(event);', 'class' => 'changeaddress', 'style' => 'width:100px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'instruction', 'options' => array('label' => 'Instruction'), 'attributes' => array('class' => 'setgoaltxt', 'style' => 'width:450px; height:120px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'address', 'options' => array('label' => 'Address'), 'attributes' => array('readonly' => 'readonly', 'class' => 'changepasstextbox'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'address1', 'options' => array(), 'attributes' => array('readonly' => 'readonly', 'class' => 'changepasstextbox'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'city', 'options' => array('label' => 'City'), 'attributes' => array('readonly' => 'readonly', 'class' => 'changeaddress', 'style' => 'width:100px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'state', 'options' => array('label' => 'State', 'value_options' => array()), 'attributes' => array('onchange' => 'getneighborhoodcities(this.value);', 'class' => 'changeaddress', 'style' => 'width:100px; height:33px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'zipcode', 'options' => array('label' => 'Zip code'), 'attributes' => array('readonly' => 'readonly', 'class' => 'changeaddress', 'style' => 'width:100px; height:30px;'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'campaign_category', 'options' => array('label' => 'Campaign category', 'value_options' => array(1 => 'Discover', 2 => 'Support')), 'attributes' => array('class' => 'setgoaltxt', 'style' => 'width:150px; height:30px;')))), 'input_filter' => array('camptitle' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty'))), 'url' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty'))), 'firstname' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'First name is required'))))), 'lastname' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Last name is required'))))), 'newaddress' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Address is required'))))), 'newcity' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'City is required'))))), 'newstate' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'State is required.'))))), 'newzipcode' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Zip code is required'))))), 'instruction' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Instruction is required'))))), 'address' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Address is required'))))), 'city' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'City is required'))))), 'zipcode' => array('required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Zip code is required'))))), 'state' => array('required' => true))));
     $form->setAttribute('method', 'post');
     return $form;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config_authentification_form');
     $factory = new Factory();
     $form = $factory->createForm($config);
     $form->add(new \MiniModule\Element\Login(), array('priority' => 1));
     return $form;
 }
예제 #11
0
 /**
  * {@inheritDoc}
  */
 protected function marshalInputFilter(array &$config, ServiceLocatorInterface $services, FormFactory $formFactory)
 {
     if ($services->has('InputFilterManager')) {
         $inputFilterFactory = $formFactory->getInputFilterFactory();
         $inputFilterFactory->setInputFilterManager($services->get('InputFilterManager'));
     }
     parent::marshalInputFilter($config, $services, $formFactory);
 }
예제 #12
0
 public function testCreatingCaptchaElementViaFormFactoryWillCreateCaptcha()
 {
     $factory = new Factory();
     $element = $factory->createElement(array('type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'foo', 'options' => array('captcha' => array('class' => 'dumb', 'options' => array('sessionClass' => 'ZendTest\\Captcha\\TestAsset\\SessionContainer')))));
     $this->assertInstanceOf('Zend\\Form\\Element\\Captcha', $element);
     $captcha = $element->getCaptcha();
     $this->assertInstanceOf('Zend\\Captcha\\Dumb', $captcha);
 }
예제 #13
0
 /**
  * Get a test form with fields setup
  *
  * @param string $alias
  * @param string $emailFieldName
  * @return \Zend\Form\FormInterface
  */
 protected function createForm($alias, $emailFieldName = 'email')
 {
     $factory = new Factory();
     $form = $factory->createForm(array('hydrator' => 'Zend\\Stdlib\\Hydrator\\ArraySerializable', 'name' => $alias, 'elements' => array(array('spec' => array('name' => 'name', 'options' => array('label' => 'Your name'))), array('spec' => array('name' => 'email', 'type' => 'Zend\\Form\\Element\\Email', 'options' => array('label' => 'Your email address'))))));
     // Register form to the form manager
     $this->formManager->shouldReceive('get')->with($alias)->andReturn($form);
     return $form;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('mini-module\\form\\config');
     $factory = new Factory();
     $form = $factory->createForm($config['mini-module\\form\\login']);
     $form->add(new Submit('submit'));
     return $form;
 }
예제 #15
0
 /**
  * Makes the form of user login
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Zend\Form\Form
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formFactory = new Factory();
     $form = $formFactory->createForm(array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'username', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'email'))), array('spec' => array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password', 'attributes' => array('class' => 'logintextbox'), 'options' => array('label' => 'password'))), array('spec' => array('name' => 'send', 'attributes' => array('type' => 'submit', 'class' => 'accbutton', 'value' => 'Sign In Now')))), 'input_filter' => array('username' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'validators' => array(new Validator\EmailAddress())), 'password' => array('required' => true))));
     $form->setAttribute('action', $serviceLocator->get('Router')->assemble(array('action' => 'login'), array('name' => 'user')));
     $form->setAttribute('method', 'post');
     $form->setAttribute('name', 'login');
     return $form;
 }
예제 #16
0
 public function formAction()
 {
     $configForm = array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'log', 'attributes' => array('size' => '20'), 'options' => array('label' => 'Login : '******'spec' => array('type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => array('value' => 'Suite')))));
     $factory = new Factory();
     $form = $factory->createForm($configForm);
     $services = $this->getServiceLocator();
     $form = $services->get('MiniModule\\Form\\Authentification');
     return array('form' => $form);
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('mini-module\\form\\config');
     $factory = new Factory();
     $form = $factory->createForm($config['mini-module\\form\\new_user']);
     $form->setAttribute('id', 'formAuthId');
     $form->add(new Submit('submit'));
     return $form;
 }
예제 #18
0
 /**
  * Creates form for a  test
  * @param string $id
  * @return \Zend\Form\Form
  */
 public function createForm($id)
 {
     $data = $this->get($id);
     $spec = json_decode($data['definition'], true);
     if (!$spec) {
         throw new \Exception('Invalid form specification');
     }
     $factory = new FormFactory();
     return $factory->create($spec);
 }
예제 #19
0
 public function setUp()
 {
     $this->target = new FactsFieldset();
     // Setup form factory.
     $factory = new Factory();
     $elements = $factory->getFormElementManager();
     $elements->setService('Core/Datepicker', new DatePicker());
     // inject form factory
     $this->target->setFormFactory($factory);
     $this->target->init();
 }
 public function createService(ServiceLocatorInterface $createService)
 {
     $factory = new Factory();
     $form = $factory->createForm(array('name' => 'promoteUserGroup', 'elements' => array(array('spec' => array('name' => 'csrf', 'type' => '\\Zend\\Form\\Element\\Csrf')), array('spec' => array('name' => 'send', 'type' => '\\Zend\\Form\\Element\\Button', 'options' => array('type' => 'submit', 'label' => 'Tell us!'), 'attributes' => array('type' => 'submit', 'label' => 'Tell us!'))))));
     $form->setHydrator(new ClassMethods());
     //             ->setInputFilter(new InputFilter());
     // Add the user fieldset, and set it as the base fieldset
     $usergroupFieldset = $createService->get('UsergroupFieldset');
     $usergroupFieldset->setUseAsBaseFieldset(true);
     $form->add($usergroupFieldset);
     return $form;
 }
 public function formAction()
 {
     /*$view = new ViewModel(array());
          $view->setTemplate("minimodule/index/form.phtml");
      	return $view;*/
     $configForm = array('elements' => array(array('spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'log', 'attributes' => array('size' => '20'), 'options' => array('label' => 'Login : '******'spec' => array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'pwd', 'attributes' => array('size' => '20'), 'options' => array('label' => 'Password : '******'spec' => array('type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => array('value' => 'Suite')))));
     $factory = new Factory();
     $form = $factory->createForm($configForm);
     $view = new ViewModel(array('form' => $form));
     $view->setTemplate("minimodule/index/form.phtml");
     return $view;
 }
 protected function createForm($config, ServiceLocatorInterface $formElements, $name, $requestedName)
 {
     $services = $formElements->getServiceLocator();
     $factory = new Factory($formElements);
     $factory->setInputFilterFactory($this->getInputFilterFactory($services));
     if (isset($config['input_filter']) && is_string($config['input_filter'])) {
         $inputFilters = $services->get('InputFilterManager');
         if ($inputFilters->has($config['input_filter'])) {
             $config['input_filter'] = $inputFilters->get($config['input_filter']);
         }
     }
     return $factory->createForm($config);
 }
 /**
  * Render buttons markup
  * @param array $aButtons
  * @return string
  */
 protected function renderButtons(array $aButtons, $bJustified = false)
 {
     $sMarkup = '';
     foreach ($aButtons as $oButton) {
         if (is_array($oButton) || $oButton instanceof Traversable && !$oButton instanceof ElementInterface) {
             $oFactory = new Factory();
             $oButton = $oFactory->create($oButton);
         } elseif (!$oButton instanceof ElementInterface) {
             throw new LogicException(sprintf('Button expects an instanceof Zend\\Form\\ElementInterface or an array / Traversable, "%s" given', is_object($oButton) ? get_class($oButton) : gettype($oButton)));
         }
         $sButtonMarkup = $this->getFormElementHelper()->__invoke($oButton);
         $sMarkup .= $bJustified ? sprintf(self::$buttonGroupJustifiedFormat, $sButtonMarkup) : $sButtonMarkup;
     }
     return $sMarkup;
 }
예제 #24
0
파일: Factory.php 프로젝트: Andyyang1981/pi
 /**
  * Create a form or form element
  *
  * @{inheritdoc}
  */
 public function create($spec)
 {
     // Canonize type
     if (isset($spec['type']) && is_string($spec['type']) && false === strpos($spec['type'], '\\')) {
         $type = strtolower($spec['type']);
         if ($type == 'form' || $type == 'fieldset') {
             $spec['type'] = sprintf('%s\\%s', __NAMESPACE__, ucfirst($type));
         } else {
             $canonizedType = str_replace(' ', '', ucwords(str_replace(array('_', '-'), ' ', $spec['type'])));
             $type = sprintf('%s\\Element\\%s', __NAMESPACE__, $canonizedType);
             if (class_exists($type)) {
                 $spec['type'] = $type;
             } else {
                 $type = sprintf('Zend\\Form\\Element\\%s', $canonizedType);
                 if (class_exists($type)) {
                     $spec['type'] = $type;
                 } else {
                     if (!isset($spec['attributes']['type'])) {
                         $spec['attributes']['type'] = $spec['type'];
                     }
                     unset($spec['type']);
                 }
             }
         }
     }
     return parent::create($spec);
 }
예제 #25
0
 /**
  * {@inheritDoc}
  */
 public function configureForm(FormInterface $form, $spec)
 {
     $this->triggerEvent(FormEvent::EVENT_CONFIGURE_FORM_PRE, $form, array('spec' => $spec));
     parent::configureForm($form, $spec);
     $this->triggerEvent(FormEvent::EVENT_CONFIGURE_FORM_POST, $form, array('spec' => $spec));
     return $form;
 }
예제 #26
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var InputFilterPluginManager $inputFilterManager */
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     /** @var array $config */
     $config = $serviceLocator->get('Config');
     $types = $config['zource_contact_fields'][$this->getConfigKey()];
     /** @var HydratorPluginManager $hydratorManager */
     $hydratorManager = $serviceLocator->get('HydratorManager');
     $hydrator = $hydratorManager->get($this->getHydratorName());
     $formFactory = new Factory($serviceLocator->get('FormElementManager'));
     /** @var FormInterface $form */
     $form = $formFactory->createForm($this->createSpec($types, $config['zource_field_types']));
     $form->setInputFilter($inputFilterManager->get($this->getInputFilterName()));
     $form->setHydrator($hydrator);
     return $form;
 }
 public function searchAction()
 {
     $elementName = $this->params()->fromRoute('element');
     $elementName = str_replace('-', '\\', $elementName);
     $term = $this->params()->fromQuery('term', '');
     $factory = new Factory();
     $element = $factory->createElement(array('type' => $elementName, 'options' => array('sm' => $this->getServiceLocator())));
     $options = $element->getOptions();
     $this->setOm($options['object_manager']);
     $proxy = $element->getProxy();
     $this->setProxy($proxy);
     $this->setOptions($options);
     $qb = $proxy->getObjectManager()->getRepository($proxy->getTargetClass())->createQueryBuilder('q');
     $driver = '';
     if (class_exists("\\Doctrine\\ORM\\QueryBuilder") && $qb instanceof \Doctrine\ORM\QueryBuilder) {
         /* @var $qb \Doctrine\ORM\QueryBuilder */
         $qb->setMaxResults(20);
         $driver = 'orm';
     } elseif (class_exists("\\Doctrine\\ODM\\MongoDB\\Query\\Builder") && $qb instanceof \Doctrine\ODM\MongoDB\Query\Builder) {
         /* @var $qb \Doctrine\ODM\MongoDB\Query\Builder */
         $qb->limit(20);
         $driver = 'odm';
     } else {
         throw new \Exception('Can\'t find ORM or ODM doctrine driver');
     }
     foreach ($options['searchFields'] as $field) {
         if ($driver == 'orm') {
             $qb->orWhere($qb->expr()->like('q.' . $field, $qb->expr()->literal("%{$term}%")));
         } elseif ($driver == 'odm') {
             $qb->addOr($qb->expr()->field($field)->equals(new \MongoRegex("/{$term}/i")));
         }
     }
     if ($options['orderBy']) {
         if ($driver == 'orm') {
             $qb->orderBy('q.' . $options['orderBy'][0], $options['orderBy'][1]);
         } elseif ($driver == 'odm') {
             $qb->sort($options['orderBy'][0], $options['orderBy'][1]);
         }
     }
     $this->setObjects($qb->getQuery()->execute());
     $valueOptions = $this->getValueOptions();
     $view = new JsonModel($valueOptions);
     return $view;
 }
예제 #28
0
 public function testCanCreateFormWithNullElements()
 {
     $form = $this->factory->createForm(array('name' => 'foo', 'elements' => array('bar' => array('spec' => array('name' => 'bar')), 'baz' => null, 'bat' => array('spec' => array('name' => 'bat')))));
     $this->assertInstanceOf('Zend\\Form\\FormInterface', $form);
     $elements = $form->getElements();
     $this->assertEquals(2, count($elements));
     $this->assertTrue($form->has('bar'));
     $this->assertFalse($form->has('baz'));
     $this->assertTrue($form->has('bat'));
 }
예제 #29
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     $this->add(array('name' => 'cedula', 'options' => array('label' => 'Cedula'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'nombres', 'options' => array('label' => 'Nombre'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'apellidos', 'options' => array('label' => 'Apellidos'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'codigo', 'options' => array('label' => 'Codigo'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'facultad', 'options' => array('label' => 'Facultad'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $radio = new Element\Radio('facultad');
     $radio->setLabel('Facultad');
     $this->add($radio);
     $radio = new Element\Radio('unidadacademica');
     $radio->setLabel('Unidad Academica');
     $this->add($radio);
     $this->add(array('name' => 'semestre', 'options' => array('label' => 'Semestre del Año'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'formacion', 'options' => array('label' => 'Formacion'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'direccion', 'options' => array('label' => 'Direccion'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $this->add(array('name' => 'telefono', 'options' => array('label' => 'Telefono'), 'attributes' => array('type' => 'text', 'class' => 'input')));
     $factory = new Factory();
     $correo = $factory->createElement(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'correo', 'options' => array('label' => 'Correo'), 'attributes' => array('class' => 'input')));
     $this->add($correo);
     //boton
     $this->add(array('name' => 'send', 'attributes' => array('type' => 'submit', 'value' => 'Guardar', 'title' => 'Guardar')));
 }
예제 #30
-6
 public function indexAction()
 {
     $services = $this->getServiceLocator();
     $config = $services->get('config');
     $translator = $services->get('translator');
     $namespaces = $this->getFlashMessengerNamespaces();
     $user = $this->getAuthInfo();
     $formFactory = new FormFactory();
     $formConfig = $config['feedback']['message_form'];
     if ($user) {
         unset($formConfig['elements']['captcha']);
     }
     $form = $formFactory->createForm($formConfig);
     if ($this->getRequest()->isPost()) {
         $form->setData($this->params()->fromPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $mail = new PHPMailer();
             $mail->setFrom($config['feedback']['support_address']);
             $mail->addReplyTo($data['email'], $data['name']);
             $mail->addAddress($config['feedback']['support_address']);
             $subject = $translator->translate($config['feedback']['message_subject']);
             $mail->Subject = str_replace('%name%', $data['name'], $subject);
             $mail->Body = $data['message'];
             $mail->send();
             $this->flashMessenger()->addSuccessMessage($translator->translate('Message was successfully sent. Thanks for feedback'));
             return $this->redirect()->refresh();
         } else {
             $this->flashMessenger()->addMessage($translator->translate('Form has errors. Check it'), $namespaces['error']);
         }
     } else {
         if ($user) {
             $form->get('name')->setValue($user->getDisplayName());
             $form->get('email')->setValue($user->getEmail());
         }
     }
     return array('form' => $form, 'title' => $config['feedback']['title'], 'description' => $config['feedback']['description'], 'display_flash_messages' => $config['feedback']['display_flash_messages']);
 }