コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     $formType = new FormType();
     $formType->setPtd($this->container->getPtd());
     $formType->setEntity('FacebookAWD\\Plugin\\Connect\\Model\\LoginButton');
     $this->generator = FormFactory::createForm($this->container->getSlug() . '_generator', $formType);
     $this->generator->build();
     return $this;
 }
コード例 #2
0
 /**
  * Parse the shortcode.
  */
 public function shortcode($options, $content = null)
 {
     $object = new $this->class();
     $this->form = FormFactory::createForm('shortcode', new FormType(), $object);
     $configs = Helper::keysToCamelCase($options);
     if ($content) {
         $configs['content'] = $content;
     }
     $form = FormFactory::createForm('shortcode', new FormType(), $object);
     $form->build();
     $form->bind(array('shortcode' => $configs));
     return call_user_func_array($this->callback, array($object));
 }
コード例 #3
0
 /**
  * {@ineritedDoc}
  */
 public function build()
 {
     parent::build();
     //add the security form to the root form
     if (!$this->hasParent()) {
         $csrfType = new FormType();
         $csrfType->setType('hidden');
         $csrfType->setMapped(false);
         $csrfForm = FormFactory::createForm(static::$CSRF_KEY, $csrfType);
         $csrfForm->setData($this->getNonce());
         $this->add(static::$CSRF_KEY, $csrfForm);
     }
 }
コード例 #4
0
ファイル: Container.php プロジェクト: pop-code/framework
 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     AnnotationRegistry::registerFile(dirname($this->getRoot()->getRootPath()) . '/vendor/pop-code/framework/src/Form/FormType.php');
     $ann = new IndexedReader(new SimpleAnnotationReader());
     $ann->addNamespace('PopCode\\Framework\\Form');
     $this->set('services.annotation_reader', $ann);
     FormFactory::setAnnotationReader($this->get('services.annotation_reader'));
     FormFactory::registerMapping('form', 'PopCode\\Framework\\Form\\Form');
     FormFactory::registerMapping('text', 'PopCode\\Framework\\Form\\TextForm');
     FormFactory::registerMapping('hidden', 'PopCode\\Framework\\Form\\HiddenForm');
     FormFactory::registerMapping('textarea', 'PopCode\\Framework\\Form\\TextareaForm');
     FormFactory::registerMapping('select', 'PopCode\\Framework\\Form\\SelectForm');
     FormFactory::registerMapping('radio', 'PopCode\\Framework\\Form\\SelectForm');
     FormFactory::registerMapping('checkbox', 'PopCode\\Framework\\Form\\SelectForm');
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     //Init screen settings form
     $screen = $this->om->get($this->container->getSlug() . '.login');
     if (!$screen instanceof WPLoginScreen) {
         $screen = new WPLoginScreen();
     } else {
         $screen = clone $screen;
     }
     $formType = new FormType();
     $formType->setPtd($this->container->getPtd());
     $formType->setEntity('FacebookAWD\\Plugin\\Connect\\Model\\WPLoginScreen');
     $this->settingsForm = FormFactory::createForm($this->container->getSlug() . '_login', $formType, $screen);
     $this->settingsForm->build();
     return $this;
 }
コード例 #6
0
ファイル: LoginButton.php プロジェクト: facebook-awd/connect
 /**
  * {@inheritdoc}
  */
 public function getFormType($propertyName, FormType $formType = null)
 {
     if ($propertyName == 'scope') {
         //get the form type associated on the model we want
         $userFieldsFormType = \PopCode\Framework\Form\FormFactory::getFormType('FacebookAWD\\Plugin\\Connect\\Model\\SubscriptionFieldsPermission', 'fields');
         //set the options
         $formType->setOptions($userFieldsFormType->getOptions());
     }
     return $formType;
 }
コード例 #7
0
ファイル: TextForm.php プロジェクト: pop-code/framework
 /**
  * {@ineritedDoc}
  */
 public function createView()
 {
     $defaults = array('type' => 'text', 'value' => (string) $this->data);
     $attrs = $this->getFormAttrs(array_merge($defaults, $this->getFormType()->getAttrs()));
     return '<input ' . FormFactory::processAttrs($attrs) . ' />';
 }
コード例 #8
0
ファイル: SelectForm.php プロジェクト: pop-code/framework
 /**
  * Create the view for radio and checkbox
  * 
  * @return string
  * @throws RuntimeException
  */
 protected function createExpandedView()
 {
     $type = $this->getFormType();
     $attrs = $this->getFormAttrs($type->getAttrs());
     if ($this->isMultiple() && $type->getType() == 'radio') {
         throw new RuntimeException('The attr of the form ' . $this->getId() . '  "multiple" cannot be set with radio.');
     }
     $html = '<div class="form-group">';
     foreach ($type->getOptions() as $option) {
         $defaults = array('type' => $type->getType(), 'value' => $option['value']);
         if (is_numeric($option['value'])) {
             if ($option['value'] == $this->data) {
                 $defaults['checked'] = 'checked';
             }
         } else {
             if (is_string($option['value'])) {
                 if ($option['value'] == $this->data) {
                     $defaults['checked'] = 'checked';
                 }
             } else {
                 if ($this->isMultiple() && is_array($this->data)) {
                     if (in_array($option['value'], $this->data)) {
                         $defaults['checked'] = 'checked';
                     }
                 }
             }
         }
         $html .= '<label class="' . $type->getType() . '-inline">';
         $html .= '<input ' . \PopCode\Framework\Form\FormFactory::processAttrs(array_merge($defaults, $attrs)) . '> ' . $this->_($option['label']);
         $html .= '</label>';
     }
     $html .= '</div>';
     return $html;
 }
コード例 #9
0
ファイル: TextareaForm.php プロジェクト: pop-code/framework
 /**
  * {@ineritedDoc}
  */
 public function createView()
 {
     $attrs = $this->getFormAttrs($this->getFormType()->getAttrs());
     return '<textarea ' . FormFactory::processAttrs($attrs) . '>' . $this->data . '</textarea>';
 }
コード例 #10
0
ファイル: Form.php プロジェクト: pop-code/framework
 /**
  * {@ineritedDoc}
  */
 public function createView()
 {
     $views = array_map(function ($form) {
         if ($form->getFormType()->getGroup()) {
             return FormFactory::createControlGroup($form, $form->createView());
         }
         return $form->createView();
     }, $this->children);
     $view = implode('', $views);
     return $view;
 }
コード例 #11
0
 /**
  * Boot the plugin
  */
 public function boot()
 {
     parent::boot();
     FormFactory::registerMapping('form', 'PopCode\\Wordpress\\Form\\Form');
     FormFactory::registerMapping('widget', 'PopCode\\Wordpress\\Form\\Form');
 }