API16

JFormField/render: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 103: Line 103:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=render
  category=render
  category=JFormField
  category=JFormField
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 01:42, 25 March 2017

<! removed transcluded page call, red link never existed >

Syntax

render(&$xml, $value, $formName, $groupName, $prefix)
Parameter Name Default Value Description
&$xml
$value
$formName
$groupName
$prefix

Defined in

libraries/joomla/form/formfield.php

Importing

jimport( 'joomla.form.formfield' );

Source Body

public function render(&$xml, $value, $formName, $groupName, $prefix)
{
        // Set the xml element object.
        $this->_element         = $xml;

        // Set the id, name, and value.
        $this->id                       = (string)$xml->attributes()->id;
        $this->name                     = (string)$xml->attributes()->name;
        $this->value            = $value;

        // Set the label and description text.
        $this->labelText        = (string)$xml->attributes()->label ? (string)$xml->attributes()->label : $this->name;
        $this->descText         = (string)$xml->attributes()->description;

        // Set the required and validate options.
        $this->required         = ((string)$xml->attributes()->required == 'true' || (string)$xml->attributes()->required == 'required');
        $this->validate         = (string)$xml->attributes()->validate;

        // Add the required class if the field is required.
        if ($this->required)
        {
                if($xml->attributes()->class)
                {
                        if (strpos((string)$xml->attributes()->class, 'required') === false) {
                                $xml->attributes()->class = $xml->attributes()->class.' required';
                        }
                }
                else
                {
                        $xml->addAttribute('class', 'required');
                }
        }

        // Set the field decorator.
        $this->decorator        = (string)$xml->attributes()->decorator;

        // Set the visibility.
        $this->hidden           = ((string)$xml->attributes()->type == 'hidden' || (string)$xml->attributes()->hidden);

        // Set the multiple values option.
        $this->multiple         = ((string)$xml->attributes()->multiple == 'true' || (string)$xml->attributes()->multiple == 'multiple');

        // Set the form and group names.
        $this->formName         = $formName;
        $this->groupName        = $groupName;

        // Set the prefix
        $this->prefix           = $prefix;

        // Set the input name and id.
        $this->inputName        = $this->_getInputName($this->name, $formName, $groupName, $this->multiple);
        $this->inputId          = $this->_getInputId($this->id, $this->name, $formName, $groupName);

        // Set the actual label and input.
        $this->label            = $this->_getLabel();
        $this->input            = $this->_getInput();

        return $this;
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples