Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 506

Warning: Incorrect key file for table './miphpf_miphpfcom/watchdog.MYI'; try to repair it query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.', 2, '', 'http://www.miphpf.com/manual/custom_widgets.html', '', '3.15.219.217', 1713943616) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Custom widgets | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Custom widgets

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.

To create custom widget derive appropriate built-in widget (or simple widget) class and override getEditableControl() method. If needed getControl() and getData() methods can be reimplemented.

getControl() returns array with template variables to be displayed for non-editable control.
getData() processes the form submissions and returns the data.

* Creating a textarea widget from text simple widget

<?php
class wsWebFormWidgetTextarea extends miWebFormFieldText  {
   
public function getEditableControl()
    {
       
$id = isset($this->_properties['id'])?' id="' . $this->_properties['id'] . '"':'';

       
// Get the submitted value
       
$value = $this->_webForm->getFormData($this->_fieldName);
       
// Escape the submitted value (protects from HTML code injections)
       
$value = miI18N::htmlEscape($value);
       
// Construct the widget HTML code
       
$widget = '<textarea name="' . $this->_fieldName . '"' . $id . '>' . $value . '</textarea>';
       
// Function returns array where keys are the fields names, and the values are their corresponding widget HTML code
       
return array($this->_fieldName => $widget);
    }
}
?>