예제 #1
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function __construct($entityManager)
 {
     parent::__construct('contatoForm');
     $this->setAttribute('method', 'post');
     $this->setAttribute('id', 'fileupload');
     $this->setEntityManager($entityManager);
     $idContato = new Element('idContato');
     $idContato->setLabel('Contato');
     $idContato->setAttributes(array('name' => 'idContato', 'id' => 'idContato', 'type' => 'hidden'));
     $this->add($idContato);
     $email = new Element('email');
     $email->setLabel('Email');
     $email->setAttributes(array('name' => 'email', 'id' => 'email', 'type' => 'text', 'class' => 'form-control'));
     $this->add($email);
     $assunto = new Element('assunto');
     $assunto->setLabel('Assunto');
     $assunto->setAttributes(array('name' => 'assunto', 'id' => 'assunto', 'type' => 'text', 'class' => 'form-control'));
     $this->add($assunto);
     $mensagem = new Element\Textarea('mensagem');
     $mensagem->setLabel('Mensagem');
     $mensagem->setAttributes(array('name' => 'mensagem', 'id' => 'mensagem', 'type' => 'textarea', 'class' => 'form-control'));
     $this->add($mensagem);
     $submit = new Element('submit');
     $submit->setValue('Salvar');
     $submit->setAttributes(array('type' => 'submit'));
     $this->add($submit);
 }
예제 #2
0
 public function prepare()
 {
     $username = new Element('username');
     $username->setLabel($this->translate('Your username'));
     $username->setAttributes(['type' => 'text', 'icon' => 'user', 'class' => 'form-control']);
     $email = new Element('email');
     $email->setLabel($this->translate('Email (used to login)'));
     $email->setAttributes(['type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $password = new Element('password');
     $password->setLabel($this->translate('Password'));
     $password->setAttributes(['type' => 'password', 'id' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
     $confirmPassword = new Element('confirm-password');
     $confirmPassword->setLabel($this->translate('Confirm Password'));
     $confirmPassword->setAttributes(['type' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
     $send = new Element('send');
     $send->setValue($this->translate('Create My Account'));
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($username);
     $this->add($email);
     $this->add($password);
     $this->add($confirmPassword);
     $this->addCaptcha();
     $this->add($send);
     parent::prepare();
 }
예제 #3
0
 public function getCompleteElement()
 {
     $element = new Element('foo');
     $element->setAttributes(array('accept' => 'value', 'accesskey' => 'value', 'alt' => 'value', 'autocomplete' => 'on', 'autofocus' => 'autofocus', 'checked' => 'checked', 'class' => 'value', 'contenteditable' => 'value', 'contextmenu' => 'value', 'dir' => 'value', 'dirname' => 'value', 'disabled' => 'disabled', 'draggable' => 'value', 'dropzone' => 'value', 'form' => 'value', 'formaction' => 'value', 'formenctype' => 'value', 'formmethod' => 'value', 'formnovalidate' => 'value', 'formtarget' => 'value', 'height' => 'value', 'hidden' => 'value', 'id' => 'value', 'lang' => 'value', 'list' => 'value', 'max' => 'value', 'maxlength' => 'value', 'min' => 'value', 'multiple' => 'multiple', 'name' => 'value', 'onabort' => 'value', 'onblur' => 'value', 'oncanplay' => 'value', 'oncanplaythrough' => 'value', 'onchange' => 'value', 'onclick' => 'value', 'oncontextmenu' => 'value', 'ondblclick' => 'value', 'ondrag' => 'value', 'ondragend' => 'value', 'ondragenter' => 'value', 'ondragleave' => 'value', 'ondragover' => 'value', 'ondragstart' => 'value', 'ondrop' => 'value', 'ondurationchange' => 'value', 'onemptied' => 'value', 'onended' => 'value', 'onerror' => 'value', 'onfocus' => 'value', 'oninput' => 'value', 'oninvalid' => 'value', 'onkeydown' => 'value', 'onkeypress' => 'value', 'onkeyup' => 'value', 'onload' => 'value', 'onloadeddata' => 'value', 'onloadedmetadata' => 'value', 'onloadstart' => 'value', 'onmousedown' => 'value', 'onmousemove' => 'value', 'onmouseout' => 'value', 'onmouseover' => 'value', 'onmouseup' => 'value', 'onmousewheel' => 'value', 'onpause' => 'value', 'onplay' => 'value', 'onplaying' => 'value', 'onprogress' => 'value', 'onratechange' => 'value', 'onreadystatechange' => 'value', 'onreset' => 'value', 'onscroll' => 'value', 'onseeked' => 'value', 'onseeking' => 'value', 'onselect' => 'value', 'onshow' => 'value', 'onstalled' => 'value', 'onsubmit' => 'value', 'onsuspend' => 'value', 'ontimeupdate' => 'value', 'onvolumechange' => 'value', 'onwaiting' => 'value', 'pattern' => 'value', 'placeholder' => 'value', 'readonly' => 'readonly', 'required' => 'required', 'size' => 'value', 'spellcheck' => 'value', 'src' => 'value', 'step' => 'value', 'style' => 'value', 'tabindex' => 'value', 'title' => 'value', 'width' => 'value', 'wrap' => 'value', 'xml:base' => 'value', 'xml:lang' => 'value', 'xml:space' => 'value', 'data-some-key' => 'value', 'option' => 'value', 'optgroup' => 'value', 'arbitrary' => 'value', 'meta' => 'value'));
     $element->setValue('value');
     return $element;
 }
예제 #4
0
 public function getCompleteElement()
 {
     $element = new Element('foo');
     $element->setAttributes(array('accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', 'autofocus' => 'autofocus', 'checked' => 'checked', 'dirname' => 'value', 'disabled' => 'disabled', 'form' => 'value', 'formaction' => 'value', 'formenctype' => 'value', 'formmethod' => 'value', 'formnovalidate' => 'value', 'formtarget' => 'value', 'height' => 'value', 'id' => 'value', 'list' => 'value', 'max' => 'value', 'maxlength' => 'value', 'min' => 'value', 'multiple' => 'multiple', 'name' => 'value', 'pattern' => 'value', 'placeholder' => 'value', 'readonly' => 'readonly', 'required' => 'required', 'size' => 'value', 'src' => 'value', 'step' => 'value', 'width' => 'value'));
     $element->setValue('value');
     return $element;
 }
예제 #5
0
 public function updateAction()
 {
     $id = $this->params()->fromRoute('id');
     if (!$id) {
         return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
     }
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     try {
         $repository = $entityManager->getRepository('AlbumDm\\Entity\\Album');
         $album = $repository->find($id);
     } catch (\Exception $ex) {
         echo $ex->getMessage();
         // this never will be seen if you don't comment the redirect
         return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
     }
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($album);
     $form->setHydrator(new DoctrineHydrator($entityManager, 'AlbumDm\\Entity\\Album'));
     $send = new Element('submit');
     $send->setValue('Go');
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     $form->bind($album);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $entityManager->persist($album);
             $entityManager->flush();
             return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
         }
     }
     return new ViewModel(array('form' => $form, 'id' => $id));
 }
예제 #6
0
 /**
  * {@inheritDoc}
  *
  * @todo do we need to set value in static element?
  * @throws Exception\BadMethodCallException
  */
 public function setValue($value)
 {
     if ($this->value !== null && $value !== null) {
         //throw new Exception\BadMethodCallException("Can't set value for static form element");
     }
     return parent::setValue($value);
 }
예제 #7
0
파일: Player.php 프로젝트: 0ida/fussi
 public function __construct()
 {
     parent::__construct('Player');
     $name = new TextElement('name');
     $name->setLabel('Name');
     $this->add($name);
     $submit = new Element('submit');
     $submit->setValue('Speichern');
     $submit->setAttributes(array('type' => 'submit'));
     $this->add($submit);
 }
 public function prepare()
 {
     $email = new Element('passwordreset-email');
     $email->setLabel($this->translate('Email'));
     $email->setAttributes(['id' => 'passwordreset-email', 'type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $this->add($email);
     $send = new Element('send');
     $send->setValue('Request password reset');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($send);
     parent::prepare();
 }
예제 #9
0
 /**
  * @param Player[] $players
  */
 public function __construct($players)
 {
     parent::__construct('PlayerToTournament');
     $select = new Select('player');
     $options = array();
     foreach ($players as $player) {
         $options[$player->getId()] = $player->getName();
     }
     $select->setValueOptions($options);
     $this->add($select);
     $submit = new Element('submit');
     $submit->setValue('Hinzufügen');
     $submit->setAttributes(array('type' => 'submit'));
     $this->add($submit);
 }
 public function prepare()
 {
     $password = new Element('password');
     $password->setLabel($this->translate('Password'));
     $password->setAttributes(['type' => 'password', 'id' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
     $confirmPassword = new Element('confirm-password');
     $confirmPassword->setLabel($this->translate('Confirm Password'));
     $confirmPassword->setAttributes(['type' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
     $send = new Element('send');
     $send->setValue($this->translate('Update password'));
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-success']);
     $this->add($password);
     $this->add($confirmPassword);
     $this->add($send);
     parent::prepare();
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function __construct($entityManager)
 {
     parent::__construct('contatoSearchForm');
     $this->setAttribute('method', 'post');
     $this->setAttribute('id', 'contatoSearch');
     $this->setAttribute('class', 'form-inline');
     $this->setEntityManager($entityManager);
     $nome = new Element('likeField');
     $nome->setAttributes(array('name' => 'likeField', 'id' => 'likeField', 'type' => 'text', 'data-ng-model' => 'list.search'));
     $nome->setLabel('Palavra Chave ');
     $this->add($nome);
     $submit = new Element('clear');
     $submit->setValue('Limpar');
     $submit->setAttributes(array('type' => 'button', 'data-ng-click' => 'list.clearSearch()'));
     $this->add($submit);
 }
예제 #12
0
 public function prepare()
 {
     $name = new Element('email');
     $name->setLabel('Your email');
     $name->setAttributes(['type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $message = new Element('message');
     $message->setLabel($this->translate('Your question or feedback'));
     $message->setAttributes(['type' => 'textarea', 'class' => 'form-control']);
     $send = new Element('send');
     $send->setValue('Submit');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($name);
     $this->add($message);
     $this->addCaptcha();
     $this->add($send);
     parent::prepare();
 }
예제 #13
0
 public function prepare()
 {
     $email = new Element('login-email');
     $email->setLabel($this->translate('Email'));
     $email->setAttributes(['id' => 'login-email-standard', 'type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $password = new Element('login-password');
     $password->setLabel($this->translate('Password'));
     $password->setAttributes(['type' => 'password', 'id' => 'login-password-standard', 'icon' => 'lock', 'class' => 'form-control']);
     $rememberMe = new Checkbox('rememberme');
     $rememberMe->setLabel($this->translate('Remember me'));
     $send = new Element('send');
     $send->setValue('Login');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($email);
     $this->add($password);
     $this->add($rememberMe);
     $this->add($send);
     parent::prepare();
 }
예제 #14
0
 public function getForm($article, $entityManager, $myEntity, $action)
 {
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($article);
     //!!!!!! Start !!!!! Added to make the association tables work with select
     foreach ($form->getElements() as $element) {
         if (method_exists($element, 'getProxy')) {
             $proxy = $element->getProxy();
             if (method_exists($proxy, 'setObjectManager')) {
                 $proxy->setObjectManager($entityManager);
             }
         }
     }
     $form->setHydrator(new DoctrineHydrator($entityManager, $myEntity));
     $oName = new Element('name');
     $oName->setAttributes(array('type' => 'text', 'maxlength' => 255));
     $oName->setOptions(array('label' => 'Название'));
     $form->add($oName, array('priority' => 1000));
     $oDescription = new Element('description');
     $oDescription->setAttributes(array('type' => 'text', 'maxlength' => 255));
     $oDescription->setOptions(array('label' => 'Описание'));
     $form->add($oDescription, array('priority' => 999));
     $send = new Element('send');
     $send->setValue($action);
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     foreach ($form->getElements() as $element) {
         $element->setAttribute('id', $element->getName());
         $element->setAttribute('class', 'form-control');
         /*if ($element->getLabel() === null) {
               $element->setOptions(array('add-on-div' => array('class'  => 'col-sm-offset-2 col-sm-10'), ));
           } else {
               $element->setOptions(array( 'add-on-div' => array('class'  => 'col-sm-10'), 
                                       'label_attributes' => array('class'  => 'col-sm-2 control-label'),
                                 ));
           }*/
     }
     return $form;
 }
예제 #15
0
$name = new Element('name');
$name->setLabel('Your name');
$name->setAttributes(array('type' => 'text'));
$email = new Element\Email('email');
$email->setLabel('Your email address');
$subject = new Element('subject');
$subject->setLabel('Subject');
$subject->setAttributes(array('type' => 'text'));
$message = new Element\Textarea('message');
$message->setLabel('Message');
$captcha = new Element\Captcha('captcha');
$captcha->setCaptcha(new Captcha\Dumb());
$captcha->setLabel('Please verify you are human');
$csrf = new Element\Csrf('security');
$send = new Element('send');
$send->setValue('Submit');
$send->setAttributes(array('type' => 'submit'));
$form = new Form('contact');
$form->add($name);
$form->add($email);
$form->add($subject);
$form->add($message);
$form->add($captcha);
$form->add($csrf);
$form->add($send);
$nameInput = new Input('name');
// configure input... and all others
$inputFilter = new InputFilter();
// attach all inputs
$form->setInputFilter($inputFilter);
$sender = new Fieldset('sender');
예제 #16
0
 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('fmi', array('action' => 'add'));
     }
     // Get the Album with the specified id.  An exception is thrown
     // if it cannot be found, in which case go to the index page.
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     try {
         // $album = $this->getAlbumTable()->getAlbum($id);
         $repository = $entityManager->getRepository('Fmi\\Entity\\User');
         // $id = (int)$this->params()->fromQuery('id', 1);
         $user = $repository->find($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('fmi', array('action' => 'index'));
     }
     // Create the form
     // 2.2)
     // $form  = new AlbumForm();
     // $form->get('submit')->setAttribute('value', 'Edit');
     // 2.2)
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($user);
     $form->setHydrator(new DoctrineHydrator($entityManager, 'Fmi\\Entity\\User'));
     // it works both ways. With the above line. and the line bellow
     //- $form->setHydrator(new DoctrineEntity($entityManager, 'Fmi\Entity\User'));
     $send = new Element('send');
     $send->setValue('Edit');
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     // 3) bind
     $form->bind($user);
     $request = $this->getRequest();
     if ($request->isPost()) {
         // $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             // $this->getAlbumTable()->saveAlbum($form->getData());
             $entityManager->persist($user);
             $entityManager->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('fmi');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
예제 #17
0
파일: Role.php 프로젝트: gotcms/gotcms
 /**
  * Initialize permissions
  *
  * @param array $userPermissions Optional
  *
  * @return \Config\Form\Role
  */
 public function initPermissions($userPermissions = array())
 {
     $permissionsTable = new Permission\Collection();
     $resources = $permissionsTable->getPermissions();
     $element = new Element('permissions');
     $data = array();
     foreach ($resources as $resource => $permissions) {
         if (empty($data[$resource])) {
             $data[$resource] = array();
         }
         foreach ($permissions as $permissionId => $permission) {
             $path = explode('/', $permission);
             if (count($path) > 1) {
                 $name = $path[0];
             } else {
                 $name = $permission;
             }
             $array = array('id' => $permissionId, 'name' => empty($path[1]) ? $permission : $path[1], 'value' => false);
             if (!empty($userPermissions[$resource]) and array_key_exists($permissionId, $userPermissions[$resource])) {
                 $array['value'] = true;
             }
             if (empty($data[$resource][$name])) {
                 $data[$resource][$name] = array();
             }
             $data[$resource][$name][] = $array;
         }
     }
     $element->setValue($data);
     $this->add($element);
 }
예제 #18
0
 public function getForm($article, $entityManager, $action)
 {
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($article);
     $form->setAttribute('enctype', 'multipart/form-data');
     //!!!!!! Start !!!!! Added to make the association tables work with select
     foreach ($form->getElements() as $element) {
         if (method_exists($element, 'getProxy')) {
             $proxy = $element->getProxy();
             if (method_exists($proxy, 'setObjectManager')) {
                 $proxy->setObjectManager($entityManager);
             }
         }
     }
     //Image article
     $titleField = new Element\File('art_image_filename');
     $titleField->setLabel('Image article');
     $form->add($titleField);
     //
     //		 $form->add(array(
     //			 'type' => 'Zend\Form\Element\Date',
     //			 'name' => 'artcCreatedDate',
     //			 'options' => array(
     //					 'label' => 'Created Date'
     //			 ),
     //			 'attributes' => array(
     //					 'min' => '2012-01-01',
     //					 'max' => '2020-01-01',
     //					 'step' => '1', // days; default step interval is 1 day
     //				 		'class' => 'datepicker'
     //			 )
     //		 ));
     //
     //		 $form->add(array(
     //			 'type' => 'Zend\Form\Element\Time',
     //			 'name' => 'artcCreatedTime',
     //			 'options'=> array(
     //					 'label' => 'Created Time'
     //			 ),
     //			 'attributes' => array(
     //					 'min' => '00:00:00',
     //					 'max' => '23:59:59',
     //					 'step' => '60', // seconds; default step interval is 60 seconds
     //			 )
     //		 ));
     $form->remove('artcCreated');
     $form->remove('parent');
     $form->remove('author');
     $form->setHydrator(new DoctrineHydrator($entityManager, 'Cms\\Entity\\Article'));
     $send = new Element('send');
     $send->setValue($action);
     // submit
     $send->setAttributes(array('type' => 'submit', 'class' => 'btn waves-effect waves-light'));
     $form->add($send);
     return $form;
 }
예제 #19
0
 public function getForm($product, $entityManager, $action)
 {
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($product);
     //!!!!!! Start !!!!! Added to make the association tables work with select
     foreach ($form->getElements() as $element) {
         if (method_exists($element, 'getProxy')) {
             $proxy = $element->getProxy();
             if (method_exists($proxy, 'setObjectManager')) {
                 $proxy->setObjectManager($entityManager);
             }
         }
     }
     $form->setHydrator(new DoctrineHydrator($entityManager, 'BkdRwd\\Entity\\Product'));
     $send = new Element('send');
     $send->setValue($action);
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     return $form;
 }
 public function updateAction()
 {
     // ------------------------ The block for Authorization
     $auth = new \Zend\Authentication\AuthenticationService();
     echo '<h1>hasIdentity = ' . $auth->hasIdentity() . '</h1>';
     $config = $this->getServiceLocator()->get('Config');
     $acl = new \CsnUser\Acl\Acl($config);
     $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
     if ($auth->hasIdentity()) {
         $usr = $auth->getIdentity();
         $usrl_id = $usr->usrl_id;
         // Use a view to get the name of the role
         // TODO we don't need that if the names of the roles are comming from the DB
         switch ($usrl_id) {
             case 1:
                 $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
                 // guest
                 break;
             case 2:
                 $role = 'member';
                 break;
             default:
                 $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
                 // guest
                 break;
         }
     }
     $controller = $this->params()->fromRoute('controller');
     $action = $this->params()->fromRoute('action');
     echo '<pre>';
     echo "controller = " . $controller . "\n";
     echo "action = " . $action . "\n";
     echo "role = " . $role . "\n";
     echo '</pre>';
     if (!$acl->hasResource($controller)) {
         throw new \Exception('Resource ' . $controller . ' not defined');
     }
     echo '<h1> Acl answer: ' . $acl->isAllowed($role, $controller, $action) . '</h1>';
     if (!$acl->isAllowed($role, $controller, $action)) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     //------------------------- End the block for Authorization
     $id = $this->params()->fromRoute('id');
     if (!$id) {
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization-acl', 'action' => 'index'));
     }
     $entityManager = $this->getEntityManager();
     try {
         $repository = $entityManager->getRepository('CsnUser\\Entity\\User');
         $user = $repository->find($id);
     } catch (\Exception $ex) {
         echo $ex->getMessage();
         // this never will be seen fi you don't comment the redirect
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization-acl', 'action' => 'index'));
     }
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($user);
     $form->setHydrator(new DoctrineHydrator($entityManager, 'CsnUser\\Entity\\User'));
     $send = new Element('send');
     $send->setValue('Edit');
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     $form->bind($user);
     $request = $this->getRequest();
     if ($request->isPost()) {
         // $form->setInputFilter(new UserFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             // ToDo raplace the code with something that uses user object
             //				$data = $form->getData();
             //				$hydrator = new ReflectionHydrator();
             //				$data  = $hydrator->extract($data); // turn the object to array
             //				unset($data['submit']);
             //				if (empty($data['usr_registration_date'])) $data['usr_registration_date'] = '2013-07-19 12:00:00';
             //				$this->getUsersTable()->update($data, array('usr_id' => $id));
             $entityManager->persist($user);
             $entityManager->flush();
             return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization-acl', 'action' => 'index'));
         }
     }
     return new ViewModel(array('form' => $form, 'id' => $id));
 }
예제 #21
0
 /**
  * Add property sub form
  *
  * @param mixed $property \Gc\Property\Model|array
  *
  * @return DocumentType
  */
 public function addProperty($property)
 {
     if (!is_array($property) and !$property instanceof Property\Model) {
         return $this;
     }
     $fieldsets = $this->getProperties();
     $name = new Element\Text('name');
     $identifier = new Element('identifier');
     $tab = new Element\Select('tab');
     $tab->setAttribute('class', 'select-tab')->setValueOptions(array());
     $datatype = new Element\Select('datatype');
     $datatype->setAttribute('class', 'select-datatype')->setValueOptions($this->datatypeCollection->getSelect());
     $description = new Element\Text('description');
     $required = new Element\Checkbox('required');
     $required->setCheckedValue('1')->setAttribute('id', 'required')->setAttribute('class', 'input-checkbox');
     $propertyId = new Element\Hidden('property_id');
     if ($property instanceof Property\Model) {
         $name->setValue($property->getName());
         $identifier->setValue($property->getIdentifier());
         $tab->setValue($property->getTabId());
         $datatype->setValue($property->getDatatypeId());
         $description->setValue($property->getDescription());
         $required->setValue((string) $property->isRequired());
         $propertyId->setValue($property->getId());
         $propertyFieldsetName = $property->getId();
     } else {
         $name->setValue($property['name']);
         $identifier->setValue($property['identifier']);
         $tab->setValue($property['tab']);
         $datatype->setValue($property['datatype']);
         $description->setValue($property['description']);
         $required->setValue((string) (!empty($property['isRequired'])));
         $propertyId->setValue(str_replace('property', '', $property['id']));
         $propertyFieldsetName = $property['id'];
     }
     $propertyForm = new FieldSet($propertyFieldsetName);
     $propertyForm->add($propertyId);
     $propertyForm->add($name);
     $propertyForm->add($identifier);
     $propertyForm->add($tab);
     $propertyForm->add($datatype);
     $propertyForm->add($description);
     $propertyForm->add($required);
     $fieldsets->add($propertyForm);
     $this->getInputFilter()->get('properties')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'tab' => array('name' => 'tab', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'datatype' => array('name' => 'datatype', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'required' => array('name' => 'required', 'required' => false, 'allow_empty' => true)), $propertyFieldsetName);
     return $this;
 }
 /**
  * {@inheritDoc}
  * Sets the "checked"-Attributes for all generated checkboxes according to the
  * respectively value.
  *
  * @uses setCheckboxesAttributes
  */
 public function setValue($value)
 {
     parent::setValue($value);
     $this->setCheckboxesAttributes($value, $this->checkboxes);
     return $this;
 }
예제 #23
0
 /**
  * @depends testCanInstantiate
  */
 public function testRenderHasFormattedValueAttribute(FormMoney $helper)
 {
     $element = new Element('foo');
     $element->setValue(1234.56);
     $helper->setLocale('de_DE');
     $markup = $helper->render($element);
     $expect = 'value="1.234,56"';
     $pos = strpos($markup, $expect);
     $this->assertGreaterThan(1, $pos);
 }
 public function updateAction()
 {
     // ------------------------ The block for Authorization
     $auth = new \Zend\Authentication\AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     $user = $auth->getIdentity();
     $usrlId = $user->usrl_id;
     // II) Protect our action
     if ($usrlId < 3) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     //------------------------- End the block for Authorization
     $id = $this->params()->fromRoute('id');
     if (!$id) {
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization', 'action' => 'index'));
     }
     $entityManager = $this->getEntityManager();
     try {
         $repository = $entityManager->getRepository('CsnUser\\Entity\\User');
         $user = $repository->find($id);
     } catch (\Exception $ex) {
         echo $ex->getMessage();
         // this never will be seen fi you don't comment the redirect
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization', 'action' => 'index'));
     }
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($user);
     $form->setHydrator(new DoctrineHydrator($entityManager, 'CsnUser\\Entity\\User'));
     $send = new Element('send');
     $send->setValue('Edit');
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     $form->bind($user);
     $request = $this->getRequest();
     if ($request->isPost()) {
         // $form->setInputFilter(new UserFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             // ToDo raplace the code with something that uses user object
             //				$data = $form->getData();
             //				$hydrator = new ReflectionHydrator();
             //				$data  = $hydrator->extract($data); // turn the object to array
             //				unset($data['submit']);
             //				if (empty($data['usr_registration_date'])) $data['usr_registration_date'] = '2013-07-19 12:00:00';
             //				$this->getUsersTable()->update($data, array('usr_id' => $id));
             $entityManager->persist($user);
             $entityManager->flush();
             return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization', 'action' => 'index'));
         }
     }
     return new ViewModel(array('form' => $form, 'id' => $id));
 }
예제 #25
0
 public function getForm($article, $entityManager, $action)
 {
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($article);
     //!!!!!! Start !!!!! Added to make the association tables work with select
     foreach ($form->getElements() as $element) {
         if (method_exists($element, 'getProxy')) {
             $proxy = $element->getProxy();
             if (method_exists($proxy, 'setObjectManager')) {
                 $proxy->setObjectManager($entityManager);
             }
         }
     }
     /*  uncomment if you need to control the data and time		
     		 $form->add(array(
     			 'type' => 'Zend\Form\Element\Date',
     			 'name' => 'artcCreatedDate',
     			 'options' => array(
     					 'label' => 'Created Date'
     			 ),
     			 'attributes' => array(
     					 'min' => '2012-01-01',
     					 'max' => '2020-01-01',
     					 'step' => '1', // days; default step interval is 1 day
     			 )
     		 ));
     
     		 $form->add(array(
     			 'type' => 'Zend\Form\Element\Time',
     			 'name' => 'artcCreatedTime',
     			 'options'=> array(
     					 'label' => 'Created Time'
     			 ),
     			 'attributes' => array(
     					 'min' => '00:00:00',
     					 'max' => '23:59:59',
     					 'step' => '60', // seconds; default step interval is 60 seconds
     			 )
     		 ));
     */
     $form->remove('artcCreated');
     $form->remove('parent');
     $form->remove('author');
     $form->setHydrator(new DoctrineHydrator($entityManager, 'CsnCms\\Entity\\Article'));
     $send = new Element('send');
     $send->setValue($action);
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     return $form;
 }
예제 #26
0
 public function manageUserAction()
 {
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     /*		
     		 $user = new User;
     		 $user->setUsrName('Stoyan');
     		 $user->setUsrPassword('Stoyan');
     		 $user->setUsrEmail('Stoyan');
     		 $user->setUsrActive(1);
     		 $entityManager->persist($user);
     		 $entityManager->flush();
     		die('I had to create something');
     */
     // 1) Update
     //		$repository = $entityManager->getRepository('Fmi\Entity\User');
     //		$id = (int)$this->params()->fromQuery('id', 1);
     //		$user = $repository->find($id);
     // instead I will create a new object
     // For new user
     $user = new User();
     // $entityManager->persist($user);
     // $detachedEntity = unserialize($serializedEntity);
     //		$detachedEntity =  new User;
     //		$user = $entityManager->merge($detachedEntity);
     // here comes the magic
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($user);
     // var_dump($builder);
     // die('After builder');
     $form->setHydrator(new DoctrineHydrator($entityManager, 'Fmi\\Entity\\User'));
     // it works both ways. With the above line. and the line bellow
     //- $form->setHydrator(new DoctrineEntity($entityManager, 'Fmi\Entity\User'));
     $form->bind($user);
     $send = new Element('send');
     $send->setValue('Submit');
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     $viewModel = new ViewModel();
     $viewModel->setVariable('form', $form);
     return $viewModel;
 }
 /**
  * If the TableModel holds information about filters that where applied, we pass them into the form element
  *
  * @param Element $element
  * @param string $fieldName
  * @return Element
  */
 protected function setElementCurrentValue(Element $element, $fieldName)
 {
     $filter = $this->tableModel->getTableFilter($fieldName);
     if ($filter && !empty($filter->getSelectedValue())) {
         $element->setValue($filter->getSelectedValue());
     }
     return $element;
 }
예제 #28
0
 /**
  * @group ZF2-450
  */
 public function testCanTranslateValue()
 {
     $element = new Element('foo');
     $element->setValue('Submit Label');
     $mockTranslator = $this->getMock('Zend\\I18n\\Translator\\Translator');
     $mockTranslator->expects($this->exactly(1))->method('translate')->will($this->returnValue('translated content'));
     $this->helper->setTranslator($mockTranslator);
     $this->assertTrue($this->helper->hasTranslator());
     $markup = $this->helper->__invoke($element);
     $this->assertContains('value="translated content"', $markup);
 }
예제 #29
0
 public function getRegistrationForm($entityManager, $user)
 {
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $form = $builder->createForm($user);
     $form->setHydrator(new DoctrineHydrator($entityManager, 'AuthDoctrin\\Entity\\User'));
     $filter = $form->getInputFilter();
     $form->remove('usrlId');
     $form->remove('lngId');
     $form->remove('usrActive');
     $form->remove('usrQuestion');
     $form->remove('usrAnswer');
     $form->remove('usrPicture');
     $form->remove('usrPasswordSalt');
     $form->remove('usrRegistrationDate');
     $form->remove('usrRegistrationToken');
     $form->remove('usrEmailConfirmed');
     // ... A lot of work of manually building the form
     $form->add(array('name' => 'usrPasswordConfirm', 'attributes' => array('type' => 'password'), 'options' => array('label' => 'Confirm Password')));
     $form->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'options' => array('label' => 'Please verify you are human', 'captcha' => new \Zend\Captcha\Figlet())));
     $send = new Element('submit');
     $send->setValue('Register');
     // submit
     $send->setAttributes(array('type' => 'submit'));
     $form->add($send);
     // ...
     return $form;
 }
예제 #30
0
 /**
  * @inheritdoc
  */
 public function setValue($value)
 {
     return $this->element->setValue($value);
 }