Source for file jforms.classic.php

Documentation is available at jforms.classic.php

  1. <?php
  2. /**
  3. @package    jelix-modules
  4. @subpackage jelix
  5. @author     Laurent Jouanneau
  6. @copyright  2010 Laurent Jouanneau
  7. @licence    http://www.gnu.org/licenses/gpl.html GNU General Public Licence, see LICENCE file
  8. */
  9.  
  10. /**
  11.  * @package    jelix-modules
  12.  * @subpackage jelix
  13.  */
  14. class jformsCtrl extends jController {
  15.  
  16.     /**
  17.     * web service for XHR request when a control should be filled with a list
  18.     * of values, depending of the value of an other control.
  19.     */
  20.     public function getListData({
  21.         $rep $this->getResponse('json'true);
  22.  
  23.         try {
  24.             $form jForms::get($this->param('__form')$this->param('__formid'));
  25.             if (!$form{
  26.                 throw new Exception ('dummy');
  27.             }
  28.         }
  29.         catch(Exception $e{
  30.             throw new Exception ('invalid form selector');
  31.         }
  32.  
  33.         // check CSRF
  34.         if ($form->securityLevel == jFormsBase::SECURITY_CSRF{
  35.             if ($form->getContainer()->token !== $this->param('__JFORMS_TOKEN__'))
  36.                 throw new jException("jelix~formserr.invalid.token");
  37.         }
  38.  
  39.         // retrieve the control to fill
  40.         $control $form->getControl($this->param('__ref'));
  41.         if (!$control || ($control instanceof jFormsControlDatasource))
  42.             throw new Exception('bad control');
  43.  
  44.         if (!($control->datasource instanceof jFormsDaoDatasource))
  45.             throw new Exception('not supported datasource type');
  46.  
  47.         $dependentControls $control->datasource->getDependentControls();
  48.         if (!$dependentControls{
  49.             throw new Exception('no dependent controls');
  50.         }
  51.  
  52.         foreach ($dependentControls as $ctname{
  53.             $form->setData($ctname$this->param($ctname));
  54.         }
  55.  
  56.         $rep->data array('data'=> $control->datasource->getData($form));
  57.  
  58.         return $rep;
  59.     }
  60.  
  61. }

Documentation generated on Wed, 04 Jan 2017 22:54:13 +0100 by phpDocumentor 1.4.3