Quick links: Content - sections - sub sections
Quick Search Advanced search

  [Opened] JForms and dynamic data through a class

Another newbie question: I tried to follow the documentation in implementing JForm and a custom class for dynamic filling a control.

test.form.xml contains:

 <?xml version="1.0" encoding="utf-8"?>
 <form xmlns="http://jelix.org/ns/forms/1.1">
   <listbox ref="icona">
    <datasource class="admin~jfd_test" />

And jfd_test.class.php contains:

 class jfd_test implements jIFormsDatasource
  protected $formId = 0;
  protected $datas = array();
  function __construct($id)
    $this->formId = $id;
    $this->datas = array (
      0 => 'test',
      1 => 'test 2',
      2 => 'Id = '. $id);
  public function getData($form)
    return ($this->datas);
  public function getLabel($key)
      return $this->datas[$key];
      return null;

I use a main template:

 <h2>Test JForm</h2>
 {form $form, 'admin~acl:save'}
    <h3>{ctrl_label 'icona'}::</h3>
    <h4>{ctrl_control 'icona'}</h4>  
  <div> {formsubmit} </div>

Finally, the controller:

 class aclCtrl extends jController 
  function index() 
      $rep = $this->getResponse('html');
      $form = jForms::create("admin~test", $this->param('id')); 
      $rep->body->assign( "form", $form );
      return $rep;

Result: it shows the form, correctly filled but stops with the following error:

Fatal error: Call to a member function isReadOnly() on a non-object in /var/www/jelix-1.1.2-dev/lib/jelix/plugins/jforms/html/html.jformsbuilder.php on line 204

Suggestions ?

  [Opened] Re: JForms and dynamic data through a class


You use an old version of jelix. Try with 1.1.3 version, by replacing the lib/ directory, and don't forget to remove all your files in the temp/yourapp/ directory.

Tell us if the issue is still there.

Note that I'm going to release the 1.1.4 version today or tomorrow.

Edit: 1.1.4 is released ! update wink

  1. Re: JForms and dynamic data through a class