Inherits from spFormEditObject.
component: cDynArea
class: spDynArea


The cDynArea component allows you to create form elements on run time, and is very useful if you have to add elements to a form dynamically. As an example, you can manually create a questionnaire with random questions and answers.


Properties


Description

Form

The main form object (the elements will be appended to this form)

Padding

Space around the component.


Methods

Remark: the functions to set properties are 'open minded'. There is no validation if the given property exists in the given component.



Returns

Description

public function addCol($rowid, $colid)

-

Add a column to the specified row. Use a number or identifier to identify the column.p


-



-


public function addField($colid, $component, $form)

field object

Add a field to the dynamic area and binds it to the given form.

public function addRow($rowid)

-

Add a row to the form. Use a number or identifier to identify the row.

public function setBGColor($theid, $bg)


Sets the background color to the given fieldname 

public function setBorder($theid, $bc, $br='')


Sets the border (and radius) to the given fieldname 

public function setDCClass($colid, $dc, $value);   


Assigns a number of units to the bootstrap grid for the given device context and column.


Valid values for $dc are:

<empty> -> 'dc', dc, dcsm, dcmd, dclg, dcxl.  

public function setDeviceClass($colid, $deviceclassmobile,$deviceclassphone,$deviceclasstablet,$deviceclassdesktop,$deviceclassdesktopxl)


A single function to set a (default) context to all devices.

public function setMargin ($theid, $m)


Sets the margin to the given fieldname

public function setPadding($theid, $p)


Set the padding to the given fieldname

public function setProperty($colid, $property, $value)


Set a field property to a value.


PHP Events

Event

Trigger

onCreate

Occurs when a component gets created

onActivate

Occurs when a component enters the Activation state

onAfterRender

Occurs when the component is rendered

onBeforeRender

Occurs when the components will start rendering (do NOT use to create components here)

onDestroy

Occurs when a component gets destroyed

onGetData

Triggers when the component requires the dynamic fields


JavaScript Events

No events

Programming

As this component is used to create components dynamical, you require code to perform this task. The working is quite similar to the form designer, you have to create rows and columsn and put your components in. To see what you need to do to create the different components, look at the runtime. A few examples are shown below.


Example:

function dynarea_1_onGetData($app)

{


  $this->addRow('row2');

  $this->addCol('col2','row2');

//  $this->setPadding('col2', 'p-1');

  $field=$this->addField('col2', new spdbradiogroup('radiogroup1', $this->form)) ;

  $this->setDCClass('col2', '', 12);

  $field->addRadioButton('M','Male','1','');

  $field->addRadioButton('F','Female','','');

  $field->addRadioButton('X','Unknown','','');

  $field->label='gender';


  $this->addRow('row3');

  $this->addCol('col3','row3');

 // $this->setPadding('col3', 'p-1');

  $this->setDCClass('col3', '', 12);

  $field=$this->addField('col3', new spdbmultiedit('multiedit1', $this->form)) ;

  $field->label='edit field';


 

  $this->addRow('row1');

  $this->addCol('col1','row1');

 // $this->setPadding('col1', 'p-1');

  $this->setBGColor('col1', 'success');

  $field=$this->addField('col1', new spDbEdit('field1', $this->form)) ;

  $this->setDCClass('col1', '', 12);

  $field->value='hallo wereld';

  $field->label='just a field';


  $this->addRow('row4');

  $this->addCol('col4','row4');

 // $this->setPadding('col3', 'p-1');

  $this->setDCClass('col4', '', 12);

  $field=$this->addField('col4', new spdblabel('dblabel1', $this->form)) ;

  $field->value='hallo wereld';

  $field->label='label field';

}